Method and terminal for ambient light detection

ABSTRACT

A method for detecting ambient light by a terminal is provided. The method includes displaying a black picture for at least two times in a first area of a display area of a display screen of a terminal, displaying an image frame picture in a second area of the display area when the black picture is displayed in the first area, displaying the image frame picture in the first area in an interval between displaying the black picture in the first area for two times, and obtaining, by the terminal, an intensity of ambient light, wherein the intensity of the ambient light is detected by a first ambient light sensor when the first area displays the black.

This application is a national stage of International Application No.PCT/CN2018/099932, filed on Aug. 10, 2018, which claims priority toInternational Application No. PCT/CN2017/120319, filed on Dec. 29, 2017.Both of the aforementioned applications are hereby incorporated byreference in their entireties.

TECHNICAL FIELD

This application relates to the field of communications technologies,and in particular, to ambient light and proximity detection methods, aphotographing method, and a terminal.

BACKGROUND

When a user uses a mobile phone, there are naturally ambient lightsources such as natural light and lamp light. The ambient light sourcesof the mobile phone affect a display effect of a display screen of themobile phone. To improve the display effect of the display screen of themobile phone, the mobile phone needs to detect ambient light, and adjustdisplay luminance of the display screen of the mobile phone based on adetection result.

Currently, ambient light may be detected by using an ambient lightsensor installed on the display screen. However, a specific field ofview (FOV) is required during detection by the ambient light sensor, andtherefore a part that is of the display screen and that is located in anFOV area of the ambient light sensor cannot be used to display apicture. This affects user experience. In addition, an optical proximitysensor and a front-facing camera of the mobile phone also need to belocated below a non-display area of the display screen. Therefore,disposing these components reduces a screen-to-body ratio of the mobilephone.

SUMMARY

Embodiments of this application provide ambient light and proximitydetection methods, a photographing method, and a terminal, so that anentire display screen of the terminal is used to display a userinterface, and this improves user experience.

According to a first aspect, an embodiment of this application providesan ambient light detection method, and the method is applied to aterminal. The terminal includes a display screen and a first ambientlight sensor. The first ambient light sensor is located under thedisplay screen. A display area of the display screen includes a firstarea and a second area. The first area includes an area used by thefirst ambient light sensor to receive ambient light, and the second areais at least a part of an area, other than the first area, in the displayarea. The method includes: controlling, by the terminal, the first areato display a black picture for at least two times; controlling, by theterminal when the first area displays the black picture, the second areato display an image frame picture; controlling, by the terminal, thefirst area to display the image frame picture in an interval betweenconsecutively displaying the black picture in the first area for twotimes; and when the first area displays the black picture, obtaining, bythe terminal, an intensity of the ambient light detected by the firstambient light sensor.

It should be noted that the terminal may be set, by default, toautomatically adjust luminance of the screen based on the ambient light.Alternatively, the terminal may provide a setting option for a user tochoose whether to enable a function of automatically adjusting luminanceof the screen based on the ambient light. If the automatic ambientlight-based adjustment function is disabled on the terminal, when theterminal works in a screen-on state, the terminal displays various userinterfaces or content in all display areas of the display screenaccording to the prior art. If the automatic ambient light-basedadjustment function is enabled on the terminal, when the terminal worksin a screen-on state, the terminal displays by using the solutionprovided in this embodiment, so that the ambient light sensor can detectthe ambient light, and the terminal displays various user interfaces orcontent in all display areas of the display screen. In other words,regardless of whether the user enables the automatic ambient light-basedadjustment function, the user can view an entire display user interfacein all the display areas of the display screen. In this way, disposingthe ambient light sensor under the display screen does not affect adisplay effect, and the automatic ambient light-based adjustmentfunction can be implemented.

The terminal controls the first area of the display screen to displaythe black picture for a plurality of times. When the first area displaysthe black pictures, the terminal obtains the intensity of the ambientlight detected by the ambient light sensor, and automatically adjustsluminance of the display screen based on the detected intensity of theambient light. This improves user experience. In addition, the terminalcontrols the first area to display the image frame picture in theinterval between consecutively displaying the black picture in the firstarea for two times, so that the entire display screen of the terminalcan be used to display the image frame picture. This improves userexperience.

In a possible design, after the obtaining, by the terminal, an intensityof the ambient light detected by the first ambient light sensor, themethod further includes: automatically adjusting, by the terminal,luminance of the display screen based on the intensity of the ambientlight detected by the first ambient light sensor.

It should be noted that, in this embodiment of this application, thefirst area of the display screen displays the black picture for theplurality of times, so that the terminal can obtain one or more ambientlight detection results in a process of refreshing one frame of picture.The terminal may automatically adjust the luminance of the displayscreen based on each ambient light detection result. Alternatively,after performing averaging, obtaining a median value, or performingother processing on the plurality of ambient light detection resultswithin a time period, the terminal may automatically adjust theluminance of the display screen based on a processing result. A methodfor adjusting the luminance of the display screen by the terminal basedon the ambient light detection result is not limited in this embodimentof this application.

In a possible design, when the terminal runs a first-type application,the terminal increases the interval between consecutively displaying theblack picture in the first area for any two times. Alternatively, whenthe terminal runs a first-type application, the terminal controls thefirst area to always display the image frame picture, and disables theambient light-based adjustment function.

Optionally, the terminal may alternatively determine, based on acurrently running application, whether to automatically enable ordisable the automatic ambient light-based adjustment function. Forexample, when the terminal runs the first-type application, the terminalmay automatically disable the ambient light-based adjustment function.Specifically, ambient light-based adjustment does not need to beperformed. Therefore, the terminal does not need to perform ambientlight detection or obtain ambient light detection data, and the terminalmay always control the display screen to perform normal display withoutdisplaying the black picture. Optionally, the terminal may determine,based on the currently running application, whether to decrease afrequency of automatic ambient light-based adjustment. For example, whenthe terminal runs the first-type application, the terminal mayautomatically increase the interval between consecutively displaying theblack picture in the first area for any two times. In other words, theterminal may decrease a frequency of displaying the black picture, afrequency of obtaining the intensity of the ambient light, and afrequency of adjusting the luminance of the screen. Disabling theambient light-based adjustment function or decreasing the frequency ofambient-based light adjustment can improve stability of displaying apicture by the terminal. This improves user experience. The first-typeapplication may be an application that has a relatively high requirementfor picture stability, for example, may be a video application, a gameapplication, or a reading application. When the terminal switches fromrunning the first-type application to running a non-first-typeapplication, the terminal may automatically enable the ambientlight-based adjustment function, or automatically increase the frequencyof ambient light-based adjustment, for example, automatically decreasethe interval between consecutively displaying the black picture in thefirst area for any two times, or increase the interval to a defaultvalue.

In a possible design, when an obtained movement speed of the terminal isgreater than a preset threshold, the terminal increases the intervalbetween consecutively displaying the black picture in the first area forany two times. Alternatively, when an obtained movement speed of theterminal is greater than a preset threshold, the terminal controls thefirst area to always display the image frame picture, and disables theambient light-based adjustment function.

Optionally, the terminal may alternatively obtain the movement speed ofthe terminal. When the obtained movement speed of the terminal isgreater than the preset threshold, the terminal may consider that theuser is running, taking a vehicle, or the like, and the user may notwant to view the display screen of the terminal or does not expect theluminance of the screen to change greatly, and may automatically disablethe ambient light-based adjustment function or decrease the frequency ofautomatic ambient light-based adjustment. When the obtained movementspeed of the terminal is less than or equal to the preset threshold, theterminal may consider that the user may want to view the display screenof the terminal, and may automatically enable the ambient light-basedadjustment function, or increase the frequency of automatic ambientlight-based adjustment.

In a possible design, when the first area displays the black picture,the intensity of the ambient light that is detected by the first ambientlight sensor and that is obtained by the terminal may include thefollowing three cases. Case 1: When the first area displays the blackpicture, the terminal controls the first ambient light sensor to detectthe intensity of the ambient light and obtain the detected intensity ofthe ambient light. When the first area displays the image frame picture,the first ambient light sensor does not work. Case 2: When the firstarea displays the black picture and the image frame picture, the firstambient light sensor is in a working state, to be specific, keepsdetecting the intensity of the ambient light. The terminal obtains, onlywhen the first area displays the black picture, the intensity of theambient light detected by the first ambient light sensor. In otherwords, the terminal obtains only the intensity of the ambient lightdetected by the ambient light sensor when the first area displays theblack picture. Case 3: similar to case 2. The first ambient light sensoris always in a working state, and the terminal also periodically obtainsthe intensity of the ambient light from the ambient light sensor.However, when adjusting the luminance of the screen, the terminal usesonly the intensity of the ambient light detected by the ambient lightsensor when the first area displays the black picture.

That the terminal controls the first area of the display screen todisplay the black picture for a plurality of times may specifically be:The terminal controls the first area to periodically or aperiodicallydisplay the black picture.

In a possible design, a display frequency of the terminal is f Hz, andthe interval between consecutively displaying, in the first areacontrolled by the terminal, the black picture for two times is greaterthan or equal to 1/(a×f) seconds, where a is a positive integer greaterthan or equal to 1.

For example, an example in which a=1 and the black picture isperiodically displayed is used for description. A period of periodicallydisplaying, in the first area controlled by the terminal, the blackpicture is 1/f. In other words, a frequency of displaying, in the firstarea controlled by the terminal, the black picture is the same as thedisplay frequency of the terminal. Within one second, the terminal maydisplay f frames of image frame pictures and the first area may alsodisplay the black picture for f times. It can be learned that, theterminal controls the first area of the display screen to display theblack picture once in each of the f frames of image frame pictures.

Therefore, the terminal may control the first area to display the blackpicture once within a time period of refreshing each frame of picture.The terminal may instruct the ambient light sensor to detect the ambientlight within a time period in which the first area displays the blackpicture. After detection by the ambient light sensor is completed, theterminal may automatically adjust the luminance of the display screenbased on a detection result. This improves user experience.

Different types of light sources may be blinking. The user may perceivea blinking of a light source in a case of a low blinking frequency. Inthis case, if the terminal detects the ambient light within a specifictime period only for a few times, and detection duration is very short,there may be a relatively great fluctuation in ambient light detectiondata. As a result, the terminal may adjust the luminance of the displayscreen to be comparatively bright or dark. To enhance adjustment of theluminance of the display screen by the terminal, in this embodiment ofthis application, a value of a may be increased to increase thefrequency of displaying the black picture, so that a frequency ofdetecting the ambient light can be increased. In other words, a quantityof times of detecting the ambient light by the terminal within aspecific time period is increased, to obtain a plurality of pieces ofdetection data within the specific time period. The plurality of piecesof detection data is filtered, for example, an average value of aplurality of pieces of detection data in one frame of picture is used toobtain relatively stable ambient light data. Further, the terminaladjusts the luminance of the display screen based on the ambient lightdata. This improves user experience.

In a possible design, duration of displaying the black picture each timeis first duration, duration required by the ambient light sensor ofdetecting the ambient light is second duration, and the first durationis greater than or equal to the second duration.

In a possible design, the image frame picture is a display userinterface presented by the terminal to the user.

In a possible design, that the terminal controls the first area todisplay the black picture for a plurality of times includes:controlling, by the terminal, the first area to display N black picturesfor a plurality of times within a first time period T1; and when thefirst area displays the black picture, the obtaining, by the terminal,an intensity of the ambient light detected by the first ambient lightsensor includes: when M of the N black pictures are displayed,separately controlling, by the terminal, the first ambient light sensorto detect the intensity of the ambient light for M times, where M isless than or equal to N; the automatically adjusting, by the terminal,luminance of the display screen based on the intensity of the detectedambient light includes: automatically adjusting, by the terminal, theluminance of the display screen based on the intensity of the ambientlight detected each time.

To be specific, when the first area displays the black picture eachtime, the terminal may control the ambient light sensor to detect theintensity of the ambient light, and automatically adjust the luminanceof the display screen based on the intensity of the ambient lightdetected each time. The terminal may alternatively control, when thefirst area displays the black picture at some time points, the ambientlight sensor to detect the intensity of the ambient light, andautomatically adjust the luminance of the display screen based on theintensity of the ambient light. When the first area displays the blackpicture at some other time points, the terminal may control the ambientlight sensor not to detect the intensity of the ambient light.

In a possible design, the terminal may increase a drive currentintensity of the first area, to increase the luminance of displaying theimage frame picture in the first area. In this way, display luminance ofthe first area is the same as luminance of other areas of the displayscreen, and the first area does not become sometimes bright andsometimes dark. This improves user experience.

In a possible design, the terminal controls the second area to displaythe black picture for a plurality of times. When the second areadisplays the black picture, the first area displays the image framepicture. The terminal controls, in an interval between consecutivelydisplaying the black picture in the second area for two times, thesecond area to display the image frame picture.

The second area may be all or a part of another display area, other thanthe first area, on the display screen. A size of the second area may begreater than or equal to a size of the first area. In addition, thedisplay screen of the terminal may include a plurality of second areas.

For example, it is assumed that the terminal currently displays a firstframe of image frame picture. When refreshing a second frame of imageframe picture, the terminal first displays a part of the black picture.A size of the part of the black picture is greater than or equal to thesize of the first area. The terminal then displays the black picture ina next area of the same size, and displays the second frame of imageframe picture in an area that just displays the black picture. Theterminal continuously moves downward to an area for displaying the blackpicture until the display screen displays the entire second frame ofimage frame picture. In this way, the terminal continuously refreshesand displays a third frame of image frame picture, a fourth frame ofimage frame picture, and the like.

Therefore, the display luminance of the first area is the same as theluminance of the other areas of the display screen, and the first areadoes not become sometimes bright and sometimes dark. This improves userexperience.

In a possible design, the terminal further includes a second ambientlight sensor, the second area includes an area used by the secondambient light sensor to receive ambient light, and the method furtherincludes: when the second area displays the black picture, obtaining, bythe terminal, an intensity of the ambient light detected by the secondambient light sensor; and automatically adjusting, by the terminal, theluminance of the display screen based on the intensity of the secondambient light detected by the second ambient light sensor.

The two ambient light sensors are disposed at a spacing from each otheron a rear side of the display screen. For example, one ambient lightsensor is disposed in a top portion of the display screen, and the otherambient light sensor is disposed at a middle position in a longitudinaldirection of the display screen. In this case, when the terminalrefreshes by using a policy 1, a policy 2, or a policy 3 in Embodiment1, the black picture sequentially covers light receiving areas of thetwo ambient light sensors, and the terminal also sequentially notifiesthe two ambient light sensors to detect the ambient light. Therefore, ina process of displaying one frame of picture, the terminal may have twotime periods for detecting the ambient light, to obtain two pieces ofdetection data.

In this way, a detection result of the ambient light sensor obtained bythe terminal is not located at a position with the same intensity of theambient light each time, for example, a position with strongest orweakest light intensity. This improves accuracy of the detection dataand enhances adjustment of the luminance of the display screen.

In a possible design, the second ambient light sensor is located in amiddle portion of the display screen.

In a possible design, the first ambient light sensor is located in a topportion of the display screen.

In a possible design, when the second area displays the black picture,the terminal controls a lower portion of the second area to display ann^(th) frame of image frame picture, and an upper portion of the secondarea to display an (n+1)^(th) frame of image frame picture; or when thesecond area displays the black picture, the terminal controls a lowerportion of the second area to display an n^(th) frame of image framepicture, and an upper portion of the second area to display the n^(th)frame of image frame picture.

In a possible design, the black picture includes a picture whosegrayscale value is less than or equal to a preset threshold.

The black picture may be a picture presented when the display screendoes not emit light. Alternatively, the black picture may be a very darkgray picture presented when the display screen emits light, and may bevisually considered as a black picture. The black picture is not limitedin this application.

An example in which the display screen of the terminal is aself-luminous screen is used for description. The terminal may turn offa light emitting unit in the first area, so that the first area displaysthe black picture. The display screen does not emit light, and thereforethe display screen is not affected by light emitted by the displayscreen. In this case, light received by the ambient light sensor byusing the display screen may be considered as the ambient light. Anaccurate ambient light detection result can be obtained when the ambientlight sensor detects the ambient light. The light emitting unit may bean LED light or the like.

Alternatively, the terminal may control a grayscale value of a displaypicture in the first area of the display screen to be less than or equalto a preset threshold, so that the first area displays the very darkgray picture. Light emitted by the display screen is relatively weak. Inthis case, the light received by the ambient light sensor by using thedisplay screen may be approximately considered as the ambient light. Arelatively accurate ambient light detection result can be obtained whenthe ambient light sensor detects the ambient light.

In a possible design, the terminal controls the display frequency and afrequency of power-frequency current of the display screen to form aphase difference.

Specifically, the terminal uses a first display frequency when the userdoes not enable the function of automatically adjusting the luminance ofthe screen based on the ambient light. The first display frequency maybe any value. The terminal uses a second display frequency when the userenables the function of automatically adjusting the luminance of thescreen based on the ambient light. There is a phase difference betweenthe second display frequency and the frequency of the power-frequencycurrent, to eliminate impact of a light source generated by thepower-frequency current, and enhance automatic adjustment of anintensity of the screen by the terminal. This improves user experience.

For example, the second frequency may be a value that is not 50 Hz or amultiple of 50 Hz, or a value that is not 60 Hz or a multiple of 60 Hz.In this way, there is a phase difference between the display frequencyand a flicker frequency of the ambient light. For example, the displayfrequency of the terminal is set to 61 Hz, 63 Hz, or the like.

According to a second aspect, a terminal is provided, including: one ormore processors, one or more memories, a display screen, and a firstambient light sensor, where the first ambient light sensor is locatedunder the display screen, and a display area of the display screenincludes a first area and a second area; the first area includes an areaused by the first ambient light sensor to receive ambient light, and thesecond area is at least a part of an area, other than the first area, inthe display area; the memory and the display screen are coupled to theprocessor; the memory is configured to store computer program code, andthe computer program code includes a computer instruction; and when theprocessor executes the computer instruction, the terminal is enabled toperform any method in the first aspect.

According to a third aspect, an ambient light detection apparatus isprovided, where the ambient light detection apparatus is included in aterminal. Alternatively, the ambient light detection apparatus is theterminal. The apparatus has a function of implementing actions of theterminal in the method in the first aspect. The function may beimplemented by hardware, or may be implemented by hardware executingcorresponding software. The hardware or software includes one or moremodules or units that correspond to the foregoing function.

According to a fourth aspect, a computer storage medium is provided,including a computer instruction. When the computer instruction runs ona terminal, the terminal is enabled to perform the ambient lightdetection method in any possible design method in the first aspect.

According to a fifth aspect, a computer program product is provided.When the computer program product runs on a computer, the computer isenabled to perform the ambient light detection method in any possibledesign method in the first aspect.

According to a sixth aspect, a data processing system is provided,including modules configured to perform the method in the first aspect.

According to a seventh aspect, an embodiment of this application furtherprovides a proximity detection solution. The ambient light sensor in themethod, the terminal, the apparatus, the computer storage medium, thecomputer program product, and the data processing system that areprovided in the foregoing aspects may be replaced with an opticalproximity sensor. A position of the optical proximity sensor in theterminal is the same as a position of the ambient light sensor in theterminal. In addition, a method for controlling, by the terminal, thedisplay screen to perform display is the same as the method forcontrolling, by the terminal, the display screen to perform display inthe foregoing ambient light detection solution. The terminal enables theoptical proximity sensor after a preset area of a display screendisplays a preset picture. A light of the optical proximity sensor emitsan optical signal. After receiving reflected light from the outside, theterminal turns off the light of the optical proximity sensor. This canavoid potential impact caused by the light of the optical proximitysensor on the screen. It should be noted that the terminal may includeboth the ambient light sensor and the optical proximity sensor. Both theambient light sensor and the optical proximity sensor may be disposed atthe same positions of the terminal provided in the foregoing aspects.

According to an eighth aspect, an embodiment of this application furtherprovides a terminal including a camera under a screen and aphotographing method using the terminal. The terminal includes thescreen and one or more cameras. At least one camera is located under thescreen. For a specific position and structure of the camera locatedunder the screen, refer to the position and a structure of the ambientlight sensor or the optical proximity sensor in the foregoing solutions.In an implementation, the camera is located under the screen and isclose to a top portion of the terminal. The photographing method usingthe terminal may include: a method for controlling, by the terminal, adisplay screen to perform display is the same as the method forcontrolling, by the terminal, the display screen to perform display inthe foregoing ambient light detection solution; after a preset area(namely, an area including the camera) of the display screen displays apreset picture, controlling, by the terminal, the camera to performexposure and obtain a preview picture, where an exposure time period isless than a time period of keeping the preset picture; and continuouslycontrolling the camera to perform exposure by refreshing one frame ofpicture after another, to display the preview picture obtained by thecamera on the display screen. This finally ensures a display effect andan imaging requirement of the camera under the screen. In thisembodiment, the camera uses a transient exposure imaging manner, and thedisplay screen uses a same refreshing method as that used in theforegoing ambient light detection solution. After a preset black pictureis displayed, the camera performs exposure. An exposure time period isless than the time period of keeping the preset picture. The preset areaperiodically refreshes the black picture, to implement photographing ofthe camera.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1a is a schematic diagram of a hardware structure of a terminalaccording to this application;

FIG. 1b is a schematic diagram of a display user interface of a terminalaccording to this application;

FIG. 2a is a schematic diagram of structural composition of a terminalaccording to this application;

FIG. 2b is a schematic diagram of structural composition of a terminalaccording to this application;

FIG. 2c is a schematic diagram of structural composition of a terminalaccording to this application;

FIG. 2d is a schematic diagram of structural composition of a terminalaccording to this application;

FIG. 2e is a schematic diagram of structural composition of a terminalaccording to this application;

FIG. 2f is a schematic diagram of structural composition of a terminalaccording to this application;

FIG. 2g is a schematic diagram of a structure of a display screenaccording to this application;

FIG. 3a is a schematic diagram of structural composition of a terminalaccording to this application;

FIG. 3b is a schematic diagram of structural composition of a terminalaccording to this application;

FIG. 4a is a schematic diagram of a receiving area of an ambient lightsensor according to this application;

FIG. 4b is a schematic diagram of a first area according to thisapplication;

FIG. 5a is a schematic diagram of refreshing a picture by a terminalaccording to this application;

FIG. 5b is a schematic diagram of refreshing a picture by a terminalaccording to this application;

FIG. 5c is a schematic diagram of refreshing a picture by a terminalaccording to this application;

FIG. 6 is a schematic diagram of refreshing a picture by a terminalaccording to this application;

FIG. 7a is a schematic diagram of refreshing a picture by a terminalaccording to this application;

FIG. 7b -1 and FIG. 7b -2 are a schematic diagram 6 of refreshing apicture by a terminal according to this application;

FIG. 8 is a schematic diagram of a correspondence between detection timeof an ambient light sensor and light intensity according to thisapplication;

FIG. 9 is a schematic diagram of a correspondence between detection timeof an ambient light sensor and light intensity according to thisapplication;

FIG. 10 is a schematic diagram of refreshing a picture by a terminalaccording to this application;

FIG. 11A, FIG. 11B, and FIG. 11C are schematic diagrams of refreshing apicture by a terminal according to this application;

FIG. 12 is a schematic diagram of refreshing a picture by a terminalaccording to this application;

FIG. 13 is a schematic diagram of structural composition of a terminalaccording to this application; and

FIG. 14 is a schematic diagram of structural composition of a terminalaccording to this application.

DESCRIPTION OF EMBODIMENTS

The terms “first” and “second” mentioned below are merely intended fordescription, and shall not be understood as an indication or implicationof relative importance or implicit indication of a quantity of indicatedtechnical features. Therefore, a feature limited by “first” or “second”may explicitly or implicitly include one or more features. In thedescriptions of this application, unless otherwise stated, “plurality”means at least two.

When a user uses a terminal, there are ambient light sources such asnatural light and lamp light. The ambient light sources of the terminalaffect a display effect of a display screen of the terminal. Currently,an ambient light sensor is installed under the display screen to detectambient light. A specific FOV is required during detection by theambient light sensor, and therefore a position that is a part of thedisplay screen and that is of the ambient light sensor cannot be used todisplay a picture. This affects user experience.

An ambient light detection method provided in this application may beperformed by a terminal. The terminal may be, for example, a mobilephone 100 shown in FIG. 1a . The method may alternatively be performedby a central processing unit (CPU) of the terminal, or a control modulethat is in the terminal and that is configured to perform the ambientlight detection method.

For example, the terminal in this application may be a mobile phonehaving a display screen (the mobile phone 100 shown in FIG. 1a ), atablet computer, a personal computer (PC), a personal digital assistant(PDA), a smart watch, a netbook, a wearable electronic device, anin-vehicle device, a household appliance having a display screen, asmart terminal, or the like. A specific form of the terminal is notspecifically limited in this application.

As shown in FIG. 1a , the terminal is the mobile phone 100. The mobilephone 100 may specifically include components such as a processor 101, aradio frequency (RF) circuit 102, a memory 103, a touchscreen 104, aBluetooth apparatus 105, one or more sensors 106, a wireless fidelity(Wi-Fi) apparatus 107, a positioning apparatus 108, an audio frequencycircuit 109, a peripheral interface 110, and a power supply apparatus111. These components may communicate by using one or morecommunications buses or signal cables (not shown in FIG. 1a ). A personskilled in the art may understand that a hardware structure shown inFIG. 1a does not constitute any limitation on the mobile phone, and themobile phone 100 may include more or fewer components than those shownin the figure, or may combine some components, or may have differentcomponent arrangements.

The following describes the components of the mobile phone 100 in detailwith reference to FIG. 1 a.

The processor 101 is a control center of the mobile phone 100. Theprocessor 101 is connected to parts of the mobile phone 100 by usingvarious interfaces and cables, runs or executes an application programstored in the memory 103, and invokes data stored in the memory 103, toperform various functions of the mobile phone 100 and process data. Insome embodiments, the processor 101 may include one or more processingunits. In some embodiments, the processor 101 may further include afingerprint verification chip, configured to verify a collectedfingerprint.

In some embodiments of this application, the processor 101 may furtherinclude one or more microcontroller units (MCU). The MCU may beconfigured to control a display picture of a display screen 104-2.Specifically, the MCU may read to-be-displayed content from the memory103, and instruct the display screen 104-2 to display a correspondingpicture.

The radio frequency circuit 102 may be configured to send and receive aradio signal in an information receiving and sending process or a callprocess. Particularly, after receiving downlink data from a basestation, the radio frequency circuit 102 may send the downlink data tothe processor 101 for processing, and sends related uplink data to thebase station. Generally, the radio frequency circuit 140 includes but isnot limited to an antenna, at least one amplifier, a transceiver, acoupler, a low noise amplifier, a duplexer, and the like. In addition,the radio frequency circuit 102 may further communicate with anotherdevice through wireless communication. The wireless communication mayuse any communications standard or protocol, including but not limitedto global system for mobile communications, general packet radioservice, code division multiple access, wideband code division multipleaccess, long term evolution, email, SMS message service, and the like.

The memory 103 is configured to store an application program and data.The processor 101 runs the application program and the data stored inthe memory 103, to execute various functions of the mobile phone 100 andprocess data. The memory 103 mainly includes a program storage area anda data storage area. The program storage area may store an operatingsystem, and an application program required by at least one function(for example, a sound playing function or an image playing function).The data storage area may store data (for example, audio data or aphonebook) created based on use of the mobile phone 100. In addition,the memory 103 may include a high-speed random access memory (RAM), andmay further include a non-volatile memory such as a magnetic diskstorage device, a flash memory device, or another volatile solid-statememory device. The memory 103 may store various operating systems suchas an iOS® operating system developed by the Apple Inc. and an Android®operating system developed by the Google Inc. The memory 103 may bestandalone, and is connected to the processor 101 by using thecommunication bus; or the memory 103 may be integrated with theprocessor 101.

The touchscreen 104 may specifically include a touchpad 104-1 and adisplay screen 104-2.

The touchpad 104-1 can collect a touch event performed by a user on ornear the mobile phone 100 (for example, an operation performed by theuser on the touchpad 104-1 or near the touchpad 104-1 by using anysuitable object such as a finger or a stylus), and send collected touchinformation to another component (such as the processor 101). The touchevent of the user near the touch panel 104-1 may be referred to asfloating touch control. The floating touch control may mean that theuser does not need to directly touch the touch panel to select, move, ordrag a target (for example, an icon), and instead, the user only needsto be near a device to implement a desired function. In addition, thetouchpad 104-1 may be implemented in a plurality of types such as aresistive type, a capacitive type, an infrared type, or a surfaceacoustic wave type.

The display screen 104-2 may be configured to display informationentered by the user, information provided for the user, and variousmenus of the mobile phone 100. The display screen 104-2 may beconfigured in a form of a liquid crystal display, an organiclight-emitting diode (OLED), or the like. The touchpad 104-1 may coverthe display screen 104-2. After detecting the touch event on or near thetouchpad 104-1, the touchpad 104-1 transfers the touch event to theprocessor 101 to determine a type of the touch event. Then, theprocessor 101 may provide corresponding visual output on the displayscreen 104-2 based on the type of the touch event. Although in FIG. 1a ,the touchpad 104-1 and the display screen 104-2 are used as twoindependent components to implement input and output functions of themobile phone 100, in some embodiments, the touchpad 104-1 and thedisplay screen 104-2 may be integrated to implement the input and outputfunctions of the mobile phone 100. It may be understood that thetouchscreen 104 is formed by stacking a plurality of layers ofmaterials. In the embodiments of this application, only the touchpad(layer) and the display screen (layer) are displayed, and another layeris not recorded in the embodiments of this application. In addition, thetouchpad 104-1 may be disposed on a front side of the mobile phone 100in a full panel form, and the display screen 104-2 may also be disposedon the front side of the mobile phone 100 in a full panel form. In thisway, a bezel-less structure can be implemented on the front side of themobile phone.

In addition, the mobile phone 100 may further have a fingerprintrecognition function. For example, a fingerprint recognizer 112 may bedisposed on a back side of the mobile phone 100 (for example, below arear-facing camera), or the fingerprint recognizer 112 may be configuredon the front side of the mobile phone 100 (for example, below thetouchscreen 104). For another example, a fingerprint collection device112 may be disposed on the touchscreen 104 to implement the fingerprintrecognition function. In other words, the fingerprint collection device112 and the touchscreen 104 may be integrated to implement thefingerprint recognition function of the mobile phone 100. In this case,the fingerprint collection device 112 is disposed on the touchscreen104, and may be a part of the touchscreen 104, or may be disposed on thetouchscreen 104 in another manner. A main component of the fingerprintcollection device 112 in the embodiments of this application is afingerprint sensor. The fingerprint sensor may use any type of sensingtechnology, which includes but is not limited to an optical sensingtechnology, a capacitive sensing technology, a piezoelectric sensingtechnology, an ultrasonic sensing technology, and the like.

The mobile phone 100 may further include a Bluetooth apparatus 105,configured to implement data exchange between the mobile phone 100 andanother short-range device (for example, a mobile phone or a smartwatch). In the embodiments of this application, the Bluetooth apparatusmay be an integrated circuit, a Bluetooth chip, or the like.

In this application, the mobile phone 100 further includes one or moreambient light sensors 106. The ambient light sensor 106 may adjustluminance of the display screen 104-2 based on an intensity of ambientlight. The one or more ambient light sensors 106 are located on the backside of the display screen 104-2. If foam or another material isdisposed on the back side of the display screen 104-2, a space of acorresponding size is reserved at a position of the ambient light sensor106 to accommodate the ambient light sensor 106.

FIG. 2a illustrates a front view of the mobile phone 100. The mobilephone 100 includes an ambient light sensor. The ambient light sensor 106may be located under the display screen of the mobile phone. As shown inFIG. 2a and FIG. 2b , in the embodiments, a direction of the back sideof the display screen 104-2, namely, a direction of the display screenaway from the front side of the mobile phone, is referred to as adirection of under the display screen. FIG. 2b shows a cross-sectionalview of the mobile phone 100 that uses an AB line as a cut-linedirection of the mobile phone 100. The ambient light sensor 106 may belocated at any position under the display screen. For example, as shownin FIG. 2c , FIG. 2d , FIG. 2e , or FIG. 2f , the ambient light sensor106 may be close to a top portion of the mobile phone and be at a middleposition (as shown in FIG. 2a ); or the ambient light sensor 106 can beclose to the top portion of the mobile phone and be at a left position(as shown in FIG. 2c and FIG. 2d ); or the ambient light sensor 106 maybe close to the top portion of the mobile phone and be at a rightposition (as shown in FIG. 2e ); or the ambient light sensor 106 may belocated under a central position of the display screen (as shown in FIG.2f ); or the display screen may be located at any other position underthe display screen. It should be noted that an area of the displayscreen corresponding to the ambient light sensor 106 may be used todisplay picture content. The ambient light sensor 106 is invisible fromthe front view of the mobile phone. The display screen covering theambient light sensor normally displays a picture in a same way asanother part of the display screen.

FIG. 3a is a front view of the mobile phone 100. For example, the mobilephone 100 includes two ambient light sensors 106. Positions of the twoambient light sensors 106 are not limited in the embodiments. Forexample, one ambient light sensor may be disposed in the top portion ofthe display screen, and the other ambient light sensor may be disposedat the central position in the longitudinal direction of the displayscreen. An area of the display screen corresponding to the ambient lightsensor 106 may be used to display a picture. In other words, the ambientlight sensor 106 is invisible from the front view of the mobile phone.It should be noted that, when there are two or more ambient lightsensors 106, the plurality of ambient light sensors 106 may be spacedfrom each other in a horizontal direction. In other words, any twoambient light sensors are not in a same row. However, the ambient lightsensors 106 may be randomly disposed in the longitudinal direction. Asshown in FIG. 3a and FIG. 3b , the two ambient light sensors are not ina same row. In other words, the sensors are spaced from each other inthe horizontal direction. However, the two ambient light sensors may bein a same column as shown in FIG. 3a , or in different columns. In otherwords, the sensors are spaced from each other in the longitudinaldirection as shown in FIG. 3b . A specific position and a relativeposition of the plurality of ambient light sensors are not limited inthe embodiments of this application.

The mobile phone 100 may further include another sensor, such as aproximity sensor or a motion sensor. Specifically, the proximity sensormay power off the display screen when the mobile phone 100 is moved toan ear. As one type of the motion sensor, an accelerometer sensor maydetect acceleration values in various directions (usually on threeaxes). The accelerometer sensor may detect a value and a direction ofgravity when the accelerometer sensor is stationary, and may be appliedto an application for recognizing a mobile phone posture (such asswitching between a landscape screen and a vertical screen, a relatedgame, and magnetometer posture calibration), a function related tovibration recognition (such as a pedometer and a knock), and the like.Other sensors such as a gyroscope, a barometer, a hygrometer, athermometer, and an infrared sensor may be further configured in themobile phone 100. Details are not described herein.

In this application, the mobile phone 100 may include one or moreoptical proximity sensors. The optical proximity sensor may sense thatan external object is approaching. The mobile phone may determine, basedon data detected by the optical proximity sensor, whether an object isapproaching, and may further perform corresponding control. For example,in a call process, when detecting that an object is approaching, themobile phone may turn off the display screen; when detecting that theobject is away, the mobile phone may turn on the display screen.Alternatively, if detecting, by using the optical proximity sensor, thatthe mobile phone is in a bag, the mobile phone does not respond to anoperation on the touchscreen. The one or more optical proximity sensorsare located on the back side of the display screen. If foam or anothermaterial is disposed on the back side of the display screen, a space ofa corresponding size is reserved at a position of the optical proximitysensor to accommodate the optical proximity sensor. In other words, theoptical proximity sensor and the ambient light sensor may be at the samepositions in the mobile phone. “The same positions” herein does not meanthat the positions of the two sensors are limited to be completely thesame. It may be understood that the two sensors are both located on theback side of the display screen, and are located in a display area ofthe display screen. In addition, the ambient light sensor shown in FIG.2a to FIG. 2g , FIG. 3a , and FIG. 3b may be replaced with the opticalproximity sensor. If the mobile phone includes both the ambient lightsensor and the optical proximity sensor, the two sensors may be disposednext to each other. To be specific, the two sensors may be disposed at arelatively small or large spacing. For example, in a solution shown inFIG. 2a to FIG. 2g , the mobile phone may further include one or oneoptical proximity sensors in addition to the ambient light sensor. Ifthe mobile phone further includes one optical proximity sensor, theoptical proximity sensor and the ambient light sensor may be in a samerow. To be specific, connection lines of the two sensors are parallelwith or approximately parallel with a top edge of a frame of the mobilephone. Alternatively, the optical proximity sensor and the ambient lightsensor may be located in different rows. To be specific, connectionlines of the two sensors are not parallel with a top edge of a frame ofthe mobile phone. In other words, the two sensors may be disposed at anypositions. If the mobile phone further includes a plurality of opticalproximity sensors, positions of the plurality of optical proximitysensors are shown in FIG. 3a and FIG. 3b . In other words, the ambientlight sensors in FIG. 3a and FIG. 3b may be replaced with the opticalproximity sensors. Alternatively, two or more optical proximity sensorsmay be added in FIG. 3a and FIG. 3b . The plurality of optical proximitysensors are spaced from each other in a horizontal direction. In otherwords, the plurality of optical proximity sensors are not in a same row.Alternatively, in an implementation, one of the two ambient lightsensors shown in FIG. 3a and FIG. 3b may be replaced with an opticalproximity sensor.

The Wi-Fi apparatus 107 is configured to provide, for the mobile phone100, network access that complies with a Wi-Fi-related standard orprotocol. The mobile phone 100 may access a Wi-Fi access point by usingthe Wi-Fi apparatus 107, to help the user send and receive an email,browse a web page, access streaming media, and the like. The Wi-Fiapparatus 107 provides a wireless broadband Internet access for theuser. In some other embodiments, the Wi-Fi apparatus 107 mayalternatively be used as a Wi-Fi wireless access point, and may provideWi-Fi network access for another device.

The positioning apparatus 108 is configured to provide a geographiclocation for the mobile phone 100. It may be understood that thepositioning apparatus 108 may be specifically a receiver of apositioning system such as a global positioning system (GPS), a BeiDounavigation satellite system, or Russian GLONASS. After receiving thegeographic location sent by the positioning system, the positioningapparatus 108 sends the information to the processor 101 for processing,or sends the information to the memory 103 for storage. In some otherembodiments, the positioning apparatus 108 may alternatively be areceiver of an assisted global positioning system (AGPS). The AGPSsystem assists the positioning apparatus 108 as an assisted server, toimplement ranging and positioning services. In this case, the assistedpositioning server communicates with a device such as the positioningapparatus 108 (namely, the GPS receiver) of the mobile phone 100 byusing a wireless communications network, to provide positioningassistance. In some other embodiments, the positioning apparatus 108 maybe a positioning technology based on a Wi-Fi access point. Because eachWi-Fi hotspot has a globally unique media access control (MAC) address,if Wi-Fi is enabled, the device may scan and collect broadcast signalsnearby Wi-Fi hotspots. Therefore, the MAC address broadcast by the Wi-Fihotspot may be obtained. The device sends, to a position server by usingthe wireless communications network, data (for example, the MAC address)that can be used to mark the Wi-Fi hotspot. The position server finds ageographic location of each Wi-Fi hotspot, and combines strength of thebroadcast signal of the Wi-Fi to calculate a geographic location of thedevice and send to the positioning apparatus 108 of the device.

The audio circuit 109, a speaker 113, and a microphone 114 may providean audio interface between the user and the mobile phone 100. The audiocircuit 109 may convert received audio data into an electrical signaland transmit the electrical signal to the speaker 113, and the speaker113 converts the electrical signal into a sound signal for output. Inaddition, the microphone 114 converts a collected sound signal into anelectrical signal, and the audio circuit 109 receives the electricalsignal, converts the electrical signal into audio data, and then outputsthe audio data to the RF circuit 102, to send the audio data to, forexample, another mobile phone, or outputs the audio data to the memory103 for further processing.

The peripheral interface 110 is configured to provide various interfacesfor an external input/output device (for example, a keyboard, a mouse,an external display screen, an external memory, or a subscriber identitymodule card). For example, the terminal is connected to the mousethrough a universal serial bus (USB) interface, and the terminal isconnected, by using a metal contact on a card slot of the subscriberidentity module card, to the subscriber identity module (SIM) cardprovided by a telecommunications operator. The peripheral interface 110may be configured to couple the external input/output peripheral deviceto the processor 101 and the memory 103.

In the embodiments of the present invention, the mobile phone 100 maycommunicate with another device in a device group by using theperipheral interface 110, for example, may receive, by using theperipheral interface 110, display data sent by another device, anddisplay the display data, and the like. This is not limited in theembodiments of the present invention.

The mobile phone 100 may further include a power supply apparatus 111(for example, a battery and a power supply management chip) thatsupplies power to the components. The battery may be logically connectedto the processor 101 by using the power supply management chip, so thatfunctions such as charging, discharging, and power consumptionmanagement are implemented by using the power supply apparatus 111.

Although not shown in FIG. 1a , the mobile phone 100 may further includea camera (a front-facing camera and/or a rear-facing camera), a flash, amicro projection apparatus, a near field communication (NFC) apparatus,and the like. Details are not described herein. The mobile phone 100 mayinclude one or more front-facing cameras. The one or more front-facingcameras are disposed on the back side of the display screen. If foam oranother material is disposed on the back side of the display screen, aspace of a corresponding size is reserved at a position of the camera toaccommodate the camera. In other words, the front-facing camera, theoptical proximity sensor, and the ambient light sensor may be at thesame positions in the mobile phone. “The same positions” herein does notmean that the positions are limited to be completely the same. It may beunderstood that the camera and the two sensors are all located on theback side of the display screen, and are located in the display area ofthe display screen. In addition, the ambient light sensor shown in FIG.2a to FIG. 2g , FIG. 3a , and FIG. 3b may be replaced with the camera.If the mobile phone includes both the ambient light sensor (or theoptical proximity sensor) and the front-facing camera, the devices maybe disposed next to each other. To be specific, the devices may bedisposed at a relatively small or large spacing. For example, in thesolution shown in FIG. 2a to FIG. 2g , the mobile phone may furtherinclude one or one front-facing cameras in addition to the ambient lightsensor. If the mobile phone further includes one front-facing camera,the front-facing camera and the ambient light sensor may be in a samerow. To be specific, connection lines of the two devices are parallelwith or approximately parallel with a top edge of a frame of the mobilephone. Alternatively, the front-facing camera and the ambient lightsensor may be located in different rows. To be specific, connectionlines of the two devices are not parallel with a top edge of a frame ofthe mobile phone. In other words, the two or three devices may bedisposed at any positions. If the mobile phone further includes aplurality of front-facing cameras, the plurality of front-facing camerasmay be disposed next to each other or may be spaced from each other. Inother words, the plurality of front-facing cameras may be in a same rowor different rows. Being in the same row means that connection lines ofthe plurality of front-facing cameras are parallel with the top edge ofthe frame of the mobile phone. In an implementation, the front-facingcamera is located at a position close to the top portion of the mobilephone.

All methods in the following embodiments may be implemented on themobile phone 100 having the foregoing hardware structure.

An embodiment of this application provides an ambient light detectionmethod, applied to a terminal having a display screen. The terminalincludes the display screen and at least one ambient light sensor. Theambient light sensor is located under the display screen. In otherwords, after the terminal is assembled, the ambient light sensor cannotbe seen from appearance of the terminal. The direction of upper thedisplay screen faces an outer surface or a front side of the terminal,and the direction of under the display screen faces an inner side or aback side of the terminal.

The terminal may be set, by default, to automatically adjust luminanceof the screen based on ambient light. Alternatively, the terminal mayprovide a setting option for a user to choose whether to enable afunction of automatically adjusting luminance of the screen based onambient light. If the automatic ambient light-based adjustment functionis disabled on the terminal, when the terminal works in a screen-onstate, the terminal displays various user interfaces or content in alldisplay areas of the display screen according to the prior art. If theautomatic ambient light-based adjustment function is enabled on theterminal, when the terminal works in a screen-on state, the terminaldisplays by using a solution provided in this embodiment, which isspecifically: The terminal controls a part of an area of the displayscreen to display a black picture for a plurality of times, to bespecific, an area covering the ambient light sensor to display the blackpicture for the plurality of times, obtains an intensity of detectedambient light when the area displays the black picture, andautomatically adjusts the luminance of the screen based on the intensityof the detected ambient light. In addition, when the area does notdisplay the black picture, the area normally displays various userinterfaces or content. The area displays the black picture for a veryshort time period, and human eyes hardly perceive the black picture.Therefore, from a perspective of the user, all the display areas of thedisplay screen can normally display various interfaces or content. Inother words, regardless of whether the user enables the automaticambient light-based adjustment function, the user can view an entiredisplay user interface in all the display areas of the display screen.In this way, disposing the ambient light sensor under the display screendoes not affect a display effect, and the automatic ambient light-basedadjustment function can be implemented.

FIG. 1b shows a setting screen of the terminal. “Automatic LuminanceAdjustment” corresponds to the function of automatically adjusting theluminance of the screen based on the ambient light by the terminal. Inresponse to a tap operation of the user on an “automatic luminanceadjustment” button, the terminal enables the function of automaticallyadjusting the luminance of the screen based on the ambient light.

Optionally, the terminal may alternatively determine, based on acurrently running application, whether to automatically enable ordisable the automatic ambient light-based adjustment function. Forexample, when the terminal runs a first-type application, the terminalmay automatically disable or stop the ambient light-based adjustmentfunction, or the terminal may automatically decrease a frequency ofambient light-based adjustment, to improve stability of displaying apicture by the terminal. This improves user experience. The first-typeapplication may be an application that has a relatively high requirementfor picture stability, for example, may be a video application, a gameapplication, or a reading application. When the terminal switches fromrunning the first-type application to running a non-first-typeapplication, the terminal may automatically enable the ambientlight-based adjustment function.

Optionally, the terminal may alternatively obtain a movement speed ofthe terminal. When the obtained movement speed of the terminal isgreater than a preset threshold, the terminal may consider that the useris running, taking a vehicle, or the like, and the user may not want toview the display screen of the terminal, and the terminal mayautomatically disable or stop the ambient light-based adjustmentfunction or further automatically decrease the frequency of ambientlight-based adjustment. When the obtained movement speed of the terminalis less than or equal to the preset threshold, the terminal may considerthat the user may want to view the display screen of the terminal, andthe terminal may automatically enable the ambient light-based adjustmentfunction.

In the ambient light detection solution provided in this embodiment ofthis application, the terminal works with the ambient light sensor toimplement ambient light-based adjustment of the display screen.Specifically, the terminal controls a part of the display screencorresponding to the ambient light sensor to display the black picture,and the terminal obtains a detection result of the ambient light by theambient light sensor when the part of the display screen displays theblack picture. The terminal adjusts the luminance of the display screenof the terminal based on the detection result. When the terminal doesnot need the detection result of the ambient light, the terminal maycontrol the part of the display screens corresponding to the ambientlight sensor to display an image frame picture. The following separatelydescribes cases in which the terminal has one ambient light sensor and aplurality of ambient light sensors.

Example 1

In this embodiment, a terminal has one ambient light sensor. A displayarea of a display screen includes a first area. The first area covers areceiving area of the ambient light sensor. The receiving area of theambient light sensor is an area in which the ambient light sensorreceives ambient light when the ambient light sensor works. A size ofthe first area is not limited in this embodiment, provided that thefirst area can cover the receiving area. The display area of the displayscreen further includes a second area. The second area is a part or allof an area, other than the first area, in the display area of thedisplay screen. The first area and the second area are located on thesame display screen.

As shown in FIG. 4a , it can be learned from characteristics of theambient light sensor that the receiving area of the ambient light sensoris a conical area, which is projected onto the display screen as acircular area with a diameter of D. In addition, there may be an opticalcrosstalk in a part, other than the circular area, in the display areaof the display screen. This may affect accuracy of receiving ambientlight data in the circular area with a diameter of D. A specific marginis usually reserved when the first area is disposed. For example, a 3-5mm width is reserved outside the circular area with a diameter of D. Inother words, the first area includes the circular area with the reservedspecific margin.

In this embodiment, the display screen may be a self-luminous displayscreen. An example in which the display screen is an OLED display screenis used to describe a working principle of the self-luminous displayscreen. The OLED display screen is a display screen made of an organicelectroluminescent diode. A display manner of the OLED display isdifferent from that of a conventional liquid crystal display (LCD), andno backlight is required. The OLED display screen is formed by a verythin coating layer of organic material and a glass substrate, and emitslight by using an electric current to drive the coating layer of organicmaterial. The emitted light may be in a monochrome such as red, green,blue, or white, and may be in full colors. It should be noted that theOLED display screen may display black by disabling a light emitting unitof the display screen.

FIG. 2g shows an example structure of the display screen. The displayscreen 104-2 has an upper surface 104-21 and a lower surface 104-22. Avinyl layer 104-23 is located on the lower surface 104-22 of the displayscreen. The ambient light sensor 106 is disposed in a hollow-out area104-24 of the vinyl layer 104-23. The ambient light sensor 106 may bedisposed on a PCF flexible board 104-25. A light-sensitive element 1061of the ambient light sensor faces the display screen 104-2 and islocated on the lower surface 104-22 of the display screen. The ambientlight sensor 106 and the display screen 104-2 may be separatelyconnected to the processor 103 by using the FPC.

A name of the vinyl layer 104-23 may vary with different functions ofthe vinyl layer 104-23. For example, a light-shielding vinyl layer has alight shielding function, a buffering vinyl layer has a bufferingfunction, a buffering and light-shielding vinyl layer has buffering andlight shielding functions, or the like. The vinyl layer may be bonded toor directly disposed on the lower surface of the display screen. Thevinyl layer in this embodiment unnecessarily has adhesion, and this isnot limited herein. In this embodiment, after the automatic ambientlight-based adjustment function is enabled on the terminal, the terminalcontrols the first area to display a black picture for at least twotimes. The terminal controls the first area to display an image framepicture in an interval between consecutively displaying the blackpicture in the first area for the at least two times. When the firstarea displays the black picture, the terminal obtains an intensity ofambient light detected by a first ambient light sensor. The terminalautomatically adjusts luminance of the display screen based on theintensity of the detected ambient light. When the first area displaysthe black picture, the terminal controls a second area to display theimage frame picture.

The black picture may be a picture presented when the display screendoes not emit light. Alternatively, the black picture may be a very darkgray picture presented when the display screen emits light, and may bevisually considered as a black picture. The black picture is not limitedin this application.

It should be noted that the terminal usually uses a grayscale value toindicate a color depth of a tone in a black and white image. White andblack are classified into several levels, according to a logarithmicrelationship, usually ranging from 0 to 255. White is 255 and black is0. Therefore, the black and white image is also referred to as agrayscale image or a grayscale picture. The terminal may control thegrayscale value of a picture displayed on the display screen to be lessthan or equal to a preset threshold, so that the terminal displays avery dark gray picture, which may be approximately considered as a blackpicture.

In other words, the terminal may also control the display screen todisplay a picture whose grayscale is dark gray, light black, or black.Specifically, the terminal classifies luminance difference between thelightest and the darkest portions into several parts, to facilitatemanagement and control of screen luminance in response to an input onthe terminal. A perceptible grayscale may be roughly classified intoseven levels: white, grayish white, light gray, gray, dark gray, lightblack, and black.

The image frame picture is a display user interface presented by theterminal to a user, and may include a specific user interface or contentdisplayed to the user.

A display frequency of the terminal is f Hz, and the interval betweenconsecutively displaying, in the first area controlled by the terminal,the black picture for two times is greater than or equal to 1/(a×f)seconds. If the black picture is periodically displayed, a period fordisplaying the black picture is 1/(a×f) seconds. In other words, theinterval between consecutively displaying the black picture for twotimes is equal to 1/(a×f) seconds, where a is a positive integer greaterthan or equal to 1.

For example, an example in which a=1 and the black picture isperiodically displayed is used for description. A period of periodicallydisplaying, in the first area controlled by the terminal, the blackpicture is 1/f. In other words, a frequency of displaying, in the firstarea controlled by the terminal, the black picture is the same as thedisplay frequency of the terminal. Within one second, the terminal maydisplay f frames of image frame pictures and the first area may alsodisplay the black picture for f times. It can be learned that, theterminal controls the first area of the display screen to display theblack picture once in each of the f frames of image frame pictures.

FIG. 6 is a schematic diagram of performing ambient light detection by aterminal. The display frequency of the terminal is f, and the period ofperiodically displaying, in the first area controlled by the terminal,the black picture is 1/f seconds. A time period t1 is a period of timein which the terminal displays one frame of image frame picture. A timeperiod t2 is a period of time in which the terminal displays the blackpicture in the first area.

To sum up, the terminal controls the first area to display the blackpicture once within a time period when the terminal refreshes each frameof picture. The terminal may instruct the ambient light sensor to detectthe ambient light within a time period in which the first area displaysthe black picture. After detection by the ambient light sensor iscompleted, the terminal may automatically adjust the luminance of thedisplay screen based on a detection result. This improves userexperience.

Different types of light sources may be blinking. The user may perceivea blinking of a light source in a case of a low blinking frequency. Inthis case, if the terminal detects the ambient light within a specifictime period only for a few times, and detection duration is very short,there may be a relatively great fluctuation in ambient light detectiondata. As a result, the terminal may adjust the luminance of the displayscreen to be comparatively bright or dark. To enhance adjustment of theluminance of the display screen by the terminal, in this embodiment ofthis application, a value of a may be increased to increase a frequencyof detecting the ambient light. In other words, a quantity of times ofdetecting the ambient light by the terminal within a specific timeperiod is increased, to obtain a plurality of pieces of detection datawithin the specific time period. The plurality of pieces of detectiondata is filtered, for example, an average value of a plurality of piecesof detection data in one frame of picture is used to obtain relativelystable ambient light data. Further, the terminal adjusts the luminanceof the display screen based on the ambient light data. This improvesuser experience.

Therefore, when a is a positive integer greater than or equal to 2, thefrequency of detecting the ambient light may be increased in thisembodiment of this application. For example, an example in which a=2 andthe black picture is periodically displayed is used for description. Aperiod of periodically displaying, in the first area controlled by theterminal, the black picture is ½f. In other words, a frequency ofdisplaying the black picture is 2f, which is two times the displayfrequency of the terminal. Within one second, the terminal may display fframes of image frame pictures and the first area displays the blackpicture for 2×f times. It can be learned that, the terminal controls thefirst area of the display screen to display the black picture for twotimes in each of the 2×f frames of image frame pictures. In other words,when the terminal displays each frame of picture, the terminal maycontrol the first area of the display screen to display the blackpicture for a times. FIG. 10 is a schematic diagram of detecting, by aterminal, the ambient light when a is 2. The display frequency of theterminal is f, and the period of periodically displaying, in the firstarea controlled by the terminal, the black picture is ½f seconds. A timeperiod t1 is a period of time in which the terminal displays one frameof image frame picture. A time period t2 and a time period t3 arerespectively a period of time when the terminal displays the blackpicture in the first area. In other words, the terminal may control thefirst area of the display screen to display the black picture in eachframe of picture in the time periods t2 and t3.

It should be noted that, when the first area displays the black pictureeach time, the terminal may control the ambient light sensor to detectthe intensity of the ambient light, and automatically adjust theluminance of the display screen based on the intensity of the ambientlight detected each time. The terminal may alternatively control, whenthe first area displays the black picture at some time points, theambient light sensor to detect the intensity of the ambient light, andautomatically adjust the luminance of the display screen based on theintensity of the ambient light. When the first area displays the blackpicture at some other time points, the terminal may control the ambientlight sensor not to detect the intensity of the ambient light.

In other words, the terminal controls the first area to display N blackpictures for a plurality of times in a first time period T1. When M ofthe N black pictures are displayed, the terminal separately controls theambient light sensor to detect an intensity of ambient light for Mtimes, where M is less than or equal to N. The terminal automaticallyadjusts the luminance of the display screen based on the intensity ofthe ambient light detected each time. When the other (N-M) blackpictures of the N black pictures are displayed, the first ambient lightsensor does not detect an intensity of ambient light.

The following description is provided by using an example in which thedisplay frequency of the terminal is f Hz, a period of periodicallydisplaying the black picture in the first area is 1/f seconds, and thefirst time period T1 is 1 second. The first area periodically displays fblack pictures within 1 second. In other words, N=f. The ambient lightsensor meets a condition of detecting the ambient light when the firstarea displays the f black pictures. In other words, the terminal has anopportunity to detect the ambient light for f times. The terminal maycontrol, at each of the f times, the ambient light sensor to detect theambient light, and obtain f detection results. In other words, M=N=f.The terminal may alternatively choose, at two or more of the f times, toperform detection, to obtain two or more detection results. In otherwords, M is greater than or equal to 2, and M is less than N.

It should be noted that the ambient light sensor needs to completedetection of the ambient light for at least once within the time periodof displaying the black picture once in the first area. In other words,duration of displaying the black picture in the first area once is firstduration, and duration of detecting the ambient light by the ambientsensor once is second duration. The first duration is greater than orequal to the second duration.

Optionally, the terminal may alternatively determine, based on acurrently running application, whether to automatically increase theinterval between consecutively displaying the black picture in the firstarea for two times. For example, when the terminal runs a first-typeapplication, the terminal may automatically increase the intervalbetween consecutively displaying the black picture in the first area fortwo times, and decrease a frequency of ambient light-based adjustment,to improve stability of displaying a picture by the terminal. Thisimproves user experience. The first-type application may be anapplication that has a relatively high requirement for picturestability, for example, may be a video application, a game application,or a reading application. When the terminal runs a non-first-typeapplication, the terminal may automatically decrease the intervalbetween consecutively displaying the black picture in the first area fortwo times, or restore the interval to a default value, and increase thefrequency of ambient light-based adjustment.

Optionally, the terminal may alternatively obtain a movement speed ofthe terminal.

When the obtained movement speed of the terminal is greater than apreset threshold, the terminal may consider that the user is running,taking a vehicle, or the like, and the user may not want to view thedisplay screen of the terminal, and may automatically increase theinterval between consecutively displaying the black picture in the firstarea for two times, and decrease the frequency of ambient light-basedadjustment. When the obtained movement speed of the terminal is lessthan or equal to the preset threshold, the terminal may consider thatthe user may want to view the display screen of the terminal, and mayautomatically decrease the interval between consecutively displaying theblack picture in the first area for two times, or restore the intervalto the default value, and increase the frequency of ambient light-basedadjustment. A process in which the terminal controls the first area ofthe display screen to display the black picture once and a process inwhich the ambient light sensor detects the ambient light once aredescribed in detail below. Details are as follows.

S101: The terminal controls the first area of the display screen tostart displaying the black picture.

The first area is a part of the display area of the terminal, and coversthe receiving area of the ambient light sensor. The receiving area ofthe ambient light sensor is the area in which the ambient light sensorreceives the ambient light when the ambient light sensor works.

For example, the terminal may determine the first area based on aposition and characteristics of the ambient light sensor. Specifically,as shown in FIG. 4b , the receiving area of the ambient light sensor 106is a conical area, which is projected onto the display screen as acircular area with a diameter of D. In addition, there may be an opticalcrosstalk in a part, other than the circular area, in the display areaof the display screen. This may affect accuracy of receiving ambientlight data in the circular area with a diameter of D. A specific marginis usually reserved when the first area is disposed. For example, a 3-5mm width is reserved outside the circular area with a diameter of D. Inother words, the first area includes the circular area with the reservedspecific margin.

It should be noted that the terminal refreshes and displays a picture ona per-row basis, and therefore the first area may be set as arectangular area that includes a circular area used by the ambient lightsensor to receive light.

FIG. 4b is a schematic diagram of the first area of the terminal. Thefirst area includes the area, namely, the receiving area, that is usedto receive the ambient light when the ambient light sensor 106 works.

The black picture may be a picture presented when the display screendoes not emit light. Alternatively, the black picture may be a very darkgray picture presented and may be visually considered as a blackpicture. The black picture is not limited in this application.

An example in which the display screen of the terminal is aself-luminous screen is used for description. The terminal may turn offa light emitting unit in the first area, so that the first area displaysthe black picture. The display screen does not emit light, and thereforethe display screen is not affected by light emitted by the displayscreen. In this case, light received by the ambient light sensor byusing the display screen may be considered as the ambient light. Anaccurate ambient light detection result can be obtained when the ambientlight sensor detects the ambient light. The light emitting unit may bean LED light or the like.

Alternatively, the terminal may control a grayscale value of a displaypicture in the first area of the display screen to be less than or equalto a preset threshold, so that the first area displays the very darkgray picture. Light emitted by the display screen is relatively weak. Inthis case, the light received by the ambient light sensor by using thedisplay screen may be approximately considered as the ambient light. Arelatively accurate ambient light detection result can be obtained whenthe ambient light sensor detects the ambient light.

In a possible implementation, the processor in the terminal may controlthe display screen to display a picture. The processor delivers adisplay instruction to the display screen. The display instructionincludes which content of a picture is displayed and which position ofthe display screen is used to display the picture. When the processordelivers an instruction to start displaying the black picture in thefirst area, the processor may record a current moment as a first moment.

For example, the following description is provided by using an examplein which the light emitting unit of the display screen is turned off todisplay the black picture in the first area of the display screen. Whenthe processor delivers an instruction to turn off the light emittingunit in the first area of the display screen, the processor records acurrent moment as a first moment.

S102: After displaying the black picture in the first area of thedisplay screen, the terminal obtains an intensity of the ambient lightdetected by the ambient light sensor.

Specifically, the first area is determined based on the position and thecharacteristics of the ambient light sensor in the terminal, andtherefore once the ambient light sensor in the terminal is determined, aposition and a size of the first area are fixed. Further, a speed and asize of refreshing a picture are definite, a time period from a timepoint at which the terminal controls the first area to start displayingthe black picture to a time point at which the first area completelydisplays the black picture may be calculated, namely, definite. The timeperiod is recorded as a time period ΔT herein.

For example, if the terminal displays the black picture by turning offthe light emitting unit in the first area of the display screen, thetime period T includes a time period from a time point at which thelight emitting unit receives a turn-off instruction to a time point atwhich the light emitting unit is completely in a turned-off state. Inother words, a start moment of the time period ΔT is a moment at whichthe terminal starts to deliver the instruction to turn off the lightemitting unit in the first area, namely, the first moment. An end momentof the time period ΔT is a moment at which the light emitting unit inthe first area is completely turned off.

For example, if the terminal displays the black picture by displaying avery dark gray picture, the time period ΔT includes a time period inwhich the first area is refreshed for displaying once. It should benoted that the first area may include a plurality of rows. Whenrefreshing the first area to display the black picture, the terminal mayrefresh and display the black picture row by row, or may refresh thefirst area by a plurality of rows.

After determining the first moment and the time period ΔT, the terminalmay determine a moment at which the first area completely displays theblack picture. The moment is recorded as a second moment. After thesecond moment, the first area completely displays the black picture, andthe terminal may obtain a detection of the ambient light detected by theambient light sensor.

Optionally, after enabling the automatic ambient light-based adjustmentfunction, the terminal may control the ambient light sensor to startdetecting the intensity of the ambient light. At this time, the ambientlight sensor detects the intensity of the ambient light regardless ofwhich picture is displayed in the first area. After the first area ofthe display screen displays the black picture, the terminal readsdetection data of the ambient light sensor at this time to adjust theluminance of the display screen. Alternatively, the terminal mayperiodically read the detection data of the ambient light sensor.However, when adjusting the luminance of the display screen, theterminal uses only the intensity of the ambient light detected by theambient light sensor when the first area displays the black picture.

Optionally, the terminal may alternatively control the ambient lightsensor to start detecting the intensity of the ambient light after thefirst area of the display screen displays the black picture, and readthe detection data of the ambient light sensor to adjust the luminanceof the display screen.

The following describes a process in detail by using the latter as anexample.

In a possible implementation, the terminal refreshes and displays apicture in sequence from a top portion of the display screen to a bottomportion of the display screen. It is assumed that the first area of theterminal is located at the top portion of the display screen. As shownin (1) in FIG. 5a , the display screen is currently displaying a firstframe of image frame picture. At the first moment, the terminal startscontrolling the first area of the display screen to display the blackpicture, and completely display the black picture after the time periodΔT, namely, at the second moment. (2) in FIG. 5a is a display userinterface of the terminal at the second moment. As shown in (2) in FIG.5a , the first area presents the black picture, and other areas presentthe first frame of image frame picture. At or after the second moment,the processor outputs a trigger signal used to instruct the ambientlight sensor to start detecting the ambient light. The trigger signalmay be a software instruction, or may be a physical interrupt signal.This is not limited in this embodiment of this application.

Further, after waiting for a specific time period, the processor in theterminal may control the display screen to refresh the first area anddisplay a second frame of image frame picture, as shown in (3) in FIG.5a . The processor continues to refresh an area below the first area anddisplay the second frame of image frame picture. As shown in (4) in FIG.5a , all display areas are refreshed and the second frame of image framepicture is displayed. The specific time period is a time period used bythe ambient light sensor to detect the ambient light, namely, the secondduration. Alternatively, after detecting the ambient light, the ambientlight sensor sends an interrupt signal to the processor, so that theprocessor controls the display screen to refresh the first area and theother areas and display the second frame of image frame picture.

In another possible implementation, the terminal refreshes and displaysa picture in sequence from a top portion of the display screen to abottom portion of the display screen. It is assumed that the first areaof the terminal is located in a non-top portion of the display screen.As shown in (1) in FIG. 5b , it is assumed that the display screen iscurrently displaying a first frame of image frame picture. The terminalcontrols the display screen to start refreshing and displaying thesecond frame of image frame picture from the top portion, as shown in(2) in FIG. 5b . At the first moment, the terminal starts controllingthe first area of the display screen to display the black picture, andcompletely display the black picture after the time period ΔT, namely,at the second moment. As shown in (3) in FIG. 5b , the terminal controlsthe ambient light sensor to start detecting the ambient light. Afterdetection is completed, the terminal controls the first area of thedisplay screen to display the second frame of image frame picture, andcontinues to refresh an area below the first area and display the secondframe of image frame picture. As shown in (4) in FIG. 5b , all displayareas are refreshed and the second frame of image frame picture isdisplayed.

In another possible implementation, the terminal may refresh and displaya picture in a non-sequential manner. The terminal may first refresh thefirst area to display the black picture. It is assumed that the firstarea is located in a non-top portion of the terminal. As shown in (1) inFIG. 5c , the display screen is currently displaying a first frame ofimage frame picture. At the first moment, the terminal startscontrolling the first area of the display screen to display the blackpicture, and completely display the black picture after the time periodΔT, namely, at the second moment. As shown in (2) in FIG. 5c , a displayuser interface of the terminal at the second moment is displayed. Asshown in (2) in FIG. 5c , the first area presents the black picture, andthe other areas present the first frame of image frame picture. At orafter the second moment, the processor outputs a trigger signal used toinstruct the ambient light sensor to start detecting the ambient light.The trigger signal may be a software instruction, or may be a physicalinterrupt signal. This is not limited in this embodiment of thisapplication.

Further, after waiting for a specific time period, the processor maycontrol the display screen to refresh the first area and display asecond frame of image frame picture, as shown in (3) in FIG. 5c . Theprocessor continues to refresh an area below the first area and displaythe second frame of image frame picture, as shown in (4) in FIG. 5c .The processor refreshes an area above the first area to display thesecond frame of image frame picture, as shown in (5) in FIG. 5c . Thespecific time period is a time period used by the ambient light sensorto detect the ambient light, namely, the second duration. Alternatively,after detecting the ambient light, the ambient light sensor sends aninterrupt signal to the processor to notify the terminal that detectionis completed. Then, the processor controls the display screen tocontinue to refresh the first area and a non-first area and display thesecond frame of image frame picture.

It should be noted that the first area cannot keep displaying the blackpicture for a long time, in other words, the first duration cannot betoo long. Otherwise, the user may perceive the black picture. Thisaffects user experience. Therefore, the ambient light sensor needs tocomplete integral detection of the ambient light within a limited time.Therefore, the ambient light sensor needs to have a capability ofcompleting detection within a millisecond- or microsecond-level integraltime. If the integral time of the ambient light sensor in the terminalis short, when the time period in which the first area displays theblack picture is a multiple of detection time of the ambient lightsensor, in other words, the first duration is at least two times thesecond duration, the terminal may control the ambient light sensor todetect the ambient light for a plurality of times in the first duration.Then, the terminal may automatically adjust the luminance of the screenbased on an average value of intensities of the ambient light detectedfor the plurality of times.

S103: The terminal adjusts the luminance of the display screen based onambient light detection data.

Specifically, the ambient light detection data includes the intensity ofthe ambient light and the like. The terminal adjusts the luminance ofthe display screen based on the ambient light detection data andaccording to a preset light adjustment policy. This improves userexperience.

For example, the terminal uses the ambient light sensor to detect theambient light. The ambient light sensor includes a photosensitive diode,an analog-to-digital converter, and a control circuit. Specifically, thephotosensitive diode converts an external ambient light signal into avoltage signal through optical-to-electrical conversion, to generate ananalog voltage signal. Then, the analog-to-digital converter convertsthe analog voltage signal into a digital signal, and sends the digitalsignal to the control circuit. The control circuit reads data of theanalog-to-digital converter at a specific interval, and processes thedata and sends the data to the terminal. This interval is generallyreferred to as integral time of the ambient light sensor. The integraltime may be set based on an actual requirement, the photosensitivediode, and the analog-to-digital converter.

It should be noted that, in this embodiment of this application, thefirst area of the display screen displays the black picture for theplurality of times, so that the terminal can obtain one or more ambientlight detection results in a process of refreshing one frame of picture.The terminal may automatically adjust the luminance of the displayscreen based on each ambient light detection result. Alternatively,after performing averaging, obtaining a median value, or performingother processing on the plurality of ambient light detection resultswithin a time period, the terminal may automatically adjust theluminance of the display screen based on a processing result. A methodfor adjusting the luminance of the display screen by the terminal basedon the ambient light detection result is not limited in this embodimentof this application.

According to the ambient light detection method provided in thisembodiment of this application, the terminal controls the first area ofthe display screen to display the black picture for a plurality oftimes. When the first area displays the black pictures, the terminalcontrols the ambient light sensor to detect the ambient light, andautomatically adjusts the luminance of the display screen based on thedetection result of the ambient light sensor. This improves userexperience. In addition, the terminal controls the first area to displaythe image frame picture in the interval between consecutively displayingthe black picture in the first area for two times, so that the entiredisplay screen of the terminal can be used to display the image framepicture. This improves user experience.

Further, when the terminal controls the first area of the display screento display the black picture for the plurality of times, the image framepicture displayed in the first area becomes sometimes bright andsometimes dark. This may be perceived by sensitive human eyes and affectuser experience.

Therefore, the terminal may increase a drive current intensity of thefirst area, to increase luminance of displaying the image frame picturein the first area. In this way, display luminance of the first area isthe same as luminance of the other areas of the display screen. Thisimproves user experience.

Alternatively, the terminal may appropriately display the black pictureat positions other than the first area, so that the first area does notbecome sometimes bright and sometimes dark. This improves userexperience.

The following describes a refresh policy used by the terminal to displaythe black picture also for a plurality of times at other positions otherthan the first area. The refresh policy is specifically as follows.

After the automatic ambient light-based adjustment function is enabledon the terminal, the terminal controls the first area to display theblack picture for at least two times. The terminal controls the firstarea to display the image frame picture in the interval betweenconsecutively displaying the black picture in the first area for the atleast two times. When the first area displays the black picture for theat least two times, the terminal obtains the intensity of the ambientlight detected by the first ambient light sensor. When the first areadisplays the black picture, the terminal controls a second area todisplay the image frame picture. In addition, the terminal furthercontrols the second area to display the black picture for a plurality oftimes. When the second area displays the black picture, the terminalcontrols the first area to display the image frame picture. In theinterval between consecutively displaying the black picture in thesecond area for two times, the terminal controls the second area todisplay the image frame picture.

The second area may be all or a part of another display area, other thanthe first area, on the display screen. A size of the second area may begreater than or equal to a size of the first area. In addition, thedisplay screen of the terminal may include a plurality of second areas.

For example, it is assumed that the terminal currently displays thefirst frame of image frame picture. When refreshing the second frame ofimage frame picture, the terminal first displays a part of the blackpicture. A size of the part of the black picture is greater than orequal to the size of the first area. The terminal then displays theblack picture in a next area of the same size, and displays the secondframe of image frame picture in an area that just displays the blackpicture. The terminal continuously moves downward to an area fordisplaying the black picture until the display screen displays theentire second frame of image frame picture. In this way, the terminalcontinuously refreshes and displays a third frame of image framepicture, a fourth frame of image frame picture, and the like.

This embodiment of this application provides three refresh policies: afirst policy, a second policy, and a third policy. Details are asfollows.

For example, FIG. 7a shows a schematic diagram of a process in which theterminal refreshes a picture. This may be marked as the first policy. Itis assumed that the terminal currently displays the first frame of imageframe picture, and displays the black picture in an area that has a samesize as the first area from the top portion of the display screen, asshown in (1) in FIG. 7a . It is assumed that the ambient light sensor islocated in the top portion of the display screen, and an area that isrefreshed for the first time to display the black picture is the firstarea. After the first area displays the black picture, the processornotifies the ambient light sensor to perform detection. After detectionby the ambient light sensor is completed, the terminal controls thedisplay screen to refresh the first area and display the second frame ofimage frame picture, and refresh an area (namely, the second area) thatis below the first area and that has a same size as the first area anddisplay the black picture, as shown in (2) in FIG. 7a . By analogy, theterminal starts refreshing the area that has displayed the black pictureto display the second frame of image frame picture, and continuouslymoves downward to an area for displaying the black picture (as shown in(3) and (4) in FIG. 7a ) until the display screen displays the entiresecond frame of image frame picture, as shown in (5) in FIG. 7a . If theambient light sensor is located at another position on the displayscreen, the refresh policy may remain unchanged, but the ambient lightsensor is notified to perform detection at a different time point.According to the refresh policy, the other areas different from thefirst area also display the black picture for the plurality of times.The second area may be a part or all of the other areas different fromthe first area. This is not limited in this embodiment.

It should be noted that, the display screen may first refresh anoriginal area that displays the black picture and display the secondframe of image frame picture, and refresh an area below the area anddisplay the black picture. Alternatively, the two refresh steps may besimultaneously performed. This is not limited in this embodiment of thisapplication.

It should be further noted that, if a size of the display area of thedisplay screen is an integer multiple of the size of the first area, asize of an area that finally displays the black picture is exactly equalto the size of the first area, as shown in (4) in FIG. 7a . If the sizeof the display area of the display screen is not an integer multiple ofthe size of the first area, and the size of the area that finallydisplays the black picture is less than the size of the first area, atime period of finally displaying the black picture may be prolonged, sothat the time period is the same as that of previously displaying theblack picture. The luminance remains unchanged and this improves userexperience.

For example, FIG. 7b -1 and FIG. 7b -2 show a schematic diagram ofanother process in which the terminal refreshes a picture. This may bemarked as the second policy. It is assumed that the terminal currentlydisplays the first frame of image frame picture. The terminal displaysthe black picture in an area that has a same size as the first area fromthe top portion of the display screen. The area is marked as an area 1.It is assumed that the ambient light sensor is located in the topportion of the display screen, and the area 1 is the first area. Afterthe first area displays the black picture, the processor notifies theambient light sensor to perform detection. At the same time, when thefirst area displays the black picture, the processor controls thedisplay screen to continue to refresh an area 2 and display the blackpicture, as shown in (1) in FIG. 7b -1. The processor controls a timeperiod of refreshing and displaying the black picture in the area 2 tobe greater than or equal to a time period of detecting the ambient lightby the ambient light sensor. After detection by the ambient light sensoris completed, in other words, after the area 2 displays the blackpicture, the processor controls to refresh the area 1 and the area 2 anddisplay the second frame of image frame picture, as shown in (2) in FIG.7b -1. Further, the processor controls an area 3 below the area 1 andthe area 2 to display the black picture, as shown in (3) in FIG. 7b -1.A size of the area 3 may be the same as a sum of sizes of the area 1 andthe area 2 By analogy, the terminal starts refreshing the area that hasdisplayed the black picture to display the second frame of image framepicture, and continuously moves downward to a position for displayingthe black picture, as shown in (3) in FIGS. 7b -1, and (4) and (5) inFIG. 7b -2, until the display screen displays the entire second frame ofimage frame picture, as shown in (6) in FIG. 7b -2. If the ambient lightsensor is located at another position on the display screen, the refreshpolicy may remain unchanged, but the ambient light sensor is notified toperform detection at a different time point. According to the refreshpolicy, the other areas (such as the area 3 and an area 4) differentfrom the first area display the black picture for the plurality oftimes. The second area may be a part or all of the other areas differentfrom the first area. For example, the second area may be the area 3, thearea 4, the area 3 and the area 4, or the like. This is not limited inthis embodiment.

It should be noted that, the display screen may first refresh anoriginal area that displays the black picture and display the secondframe of image frame picture, and refresh an area below the area anddisplay the black picture. Alternatively, the two refresh steps may besimultaneously performed. This is not limited in this embodiment of thisapplication.

It should be noted that, if a size of the display area of the displayscreen is an integer multiple of a sum of sizes of the area 1 and thearea 2, a size of an area that finally displays the black picture isexactly equal to the sum of the sizes of the area 1 and the area 2, asshown in (4) in FIG. 7b -2. If the size of the display area of thedisplay screen is not an integer multiple of the sum of the sizes of thearea 1 and the area 2, and the size of the area that finally displaysthe black picture is less than the sum of the sizes of the area 1 andthe area 2, a time period of finally displaying the black picture may beprolonged, so that the time period is the same as that of previouslydisplaying the black picture. The luminance remains unchanged and thisimproves user experience.

FIG. 11IG, 11A, FIG. 11B, and FIG. 11C show a schematic diagram of stillanother process in which the terminal refreshes a picture. This may bemarked as the third policy. Specifically, it is assumed that theterminal currently displays the first frame of image frame picture. Theterminal displays the black picture in an area that has a same size asthe first area from the top portion of the display screen, as shown in(1) in FIG. 11A. A black picture that is first displayed may be markedas a first black picture. It is assumed that the ambient light sensor islocated in the top portion of the display screen, and an area that isrefreshed and displays the black picture for the first time is marked asthe first area. The terminal moves downward to a position for displayingthe first black picture, and an original position that displays thefirst black picture starts displaying the second frame of image framepicture, as shown in (2) in FIG. 11A. As shown in (3) in FIG. 11A, theterminal continuously moves downward to a position for displaying thefirst black picture, until a specific position on the display screendisplays the first black picture. For example, the specific position maybe a central position in a longitudinal direction of the display screen,as shown in (4) in FIG. 11B. After the specific position displays thefirst black picture, the terminal continuously moves downward to aposition for displaying the first black picture. At the same time, aposition in the top portion of the display screen starts to display anew black picture, which may be marked as a second black picture. Itshould be noted that, the picture currently displayed on the displayscreen includes two black pictures: the first black picture and thesecond black picture. The terminal continuously moves downward topositions for separately displaying the first black picture and thesecond black picture on the display screen, and the original positionsfor displaying the two black pictures continue to display the secondframe of image frame picture, until a bottom portion of the displayscreen displays the first black picture, as shown in (6) in FIG. 11C. Asshown in (7) in FIG. 11C, the terminal continuously moves downward to aposition for displaying the second black picture, and a position in thetop portion of the display screen displays a new black picture again,which may be marked as a third black picture. As shown in (8) in FIG.11C, the terminal continuously moves downward to positions fordisplaying the second black picture and the third black picture, theoriginal position for displaying the second black picture displays thesecond frame of image frame picture, and the original position fordisplaying the third black picture starts displaying a third frame ofimage frame picture. The terminal continuously moves downward topositions for displaying the second black picture and the third blackpicture. This refresh mechanism is continuously repeated subsequently.It should be noted that the first black picture, the second blackpicture, and the third black picture herein are merely used for ease ofdescription. Whether the three black pictures are the same is notlimited. According to the third policy, two areas of the display screenmay simultaneously display black pictures at a moment, for example, thesimultaneously displayed first black picture and the second blackpicture, or the simultaneously displayed second black picture and thethird black picture. The second area may be a part or all of the otherareas different from the first area. This is not limited in thisembodiment.

It should be noted that, in a refresh process according to the policy 3,when the first area displays the black picture, the terminal startsperforming ambient light detection. For a specific detection method,refer to the foregoing detection method. Details are not describedherein again. It should be noted that, in a refresh method according tothe policy 3, within a time period of refreshing a frame of picture, theterminal displays black pictures in the first area for two time periods,within which the ambient light may be detected. The terminal may performdetection in the two time periods or in one of the time periods. This isnot limited in this embodiment of this application. If the terminaldetects the ambient light both within the two time periods, it isequivalent to that the terminal detects the ambient light for two timeswithin the time period of refreshing a frame of picture. In this way,the terminal does not detect positions with a same intensity of theambient light, for example, positions with highest or lowest lightintensity, the display screen being adjusted does not becomecomparatively bright or dark. This improves user experience.

It should be noted that, to illustrate a display effect, “movingdownward to a position for displaying the black picture” is described indescriptions of the refresh policies. To implement moving downward to aposition for displaying the black picture, the terminal sequentiallycontrols different areas from top to bottom to display the blackpicture. Each area displays the black picture for a plurality of timesor periodically displays the black picture.

As shown in FIG. 12, the display area of the display screen of theterminal may be divided into a plurality of areas whose sizes are thesame as the size of the first area. The areas are respectively marked asan area A, an area B, an area C, and the like. In a process in which theterminal controls the areas of the terminal to periodically display theblack picture, the terminal may move downward to a position fordisplaying the black picture as follows: The terminal controls the areaA of the display screen to display black, controls the area A of thedisplay screen to display the image frame picture after a time period,and controls the area B to display the black picture. Then, the terminalcontrols the area B of the display screen to display the image framepicture after a time period, and controls the area C to display theblack picture. Further, the terminal controls the area C of the displayscreen to display the image frame picture after a time period, andcontrols the area D to display the black picture. By analogy, until theterminal controls an area I of the display screen to display the blackpicture, and controls the area I of the display screen to display theimage frame picture after a time period.

Example 2

An envelope phenomenon may occur if a flicker frequency of ambient lightis the same as or approximate to a display frequency of a terminal. Asshown in FIG. 8, a waveform diagram in FIG. 8 is a light intensity trenddiagram of ambient light. If the display frequency of the terminal isthe same as the flicker frequency of the ambient light, when the ambientlight is detected once in one frame of picture, the terminal may detectpositions with a same intensity of the ambient light, for example,positions with highest or lowest light intensity. When the terminaladjusts luminance of a display screen based on detection data, thedisplay screen may be comparatively bright or dark. Therefore, in thisembodiment of this application, the terminal may further use two or moreambient light sensors to detect the ambient light for two or more timesin one frame of picture, to improve detection data accuracy.

The following describes by using an example in which the terminal hastwo ambient light sensors.

In this embodiment, the terminal has two ambient light sensors: a firstambient light sensor and a second ambient light sensor. A display areaof the display screen includes a first area and a second area. The firstarea covers a receiving area of the first ambient light sensor. In otherwords, the first area is an area in which the first ambient light sensorreceives ambient light when the first ambient light sensor works. Thesecond area covers a receiving area of the second ambient light sensor.In other words, the second area is an area in which the second ambientlight sensor receives ambient light when the second ambient light sensorworks. A size of the second area is not limited in this embodiment,provided that the second area can cover the receiving area.

An ambient light detection method provided in this embodiment mayinclude the following process.

The terminal controls the first area to display a black picture for atleast two times, and controls the first area to display an image framepicture in an interval between consecutively displaying the blackpicture in the first area for two times. When the first area displaysthe black picture for the at least two times, the terminal obtains anintensity of the ambient light detected by the first ambient lightsensor. When the first area displays the black picture, the terminalcontrols the second area to display the image frame picture. Theterminal further controls the second area to display the black picturefor a plurality of times. When the second area displays the blackpicture, the terminal obtains an intensity of the ambient light detectedby the second ambient light sensor. The terminal automatically adjuststhe luminance of the display screen separately based on the intensitiesof the ambient light detected by the second ambient light sensor and thefirst ambient light sensor.

The two ambient light sensors are disposed at a spacing from each otheron a rear side of the display screen. For example, as shown in FIG. 2b ,one ambient light sensor is disposed in a top portion of the displayscreen, and the other ambient light sensor is disposed at a middleposition in a longitudinal direction of the display screen. In thiscase, when the terminal refreshes by using a policy 1, a policy 2, or apolicy 3 in Embodiment 1, the black picture sequentially covers lightreceiving areas of the two ambient light sensors, and the terminal alsosequentially notifies the two ambient light sensors to detect theambient light. Therefore, in a process of displaying one frame ofpicture, the terminal may have two time periods for detecting theambient light, to obtain two pieces of detection data.

It should be noted that the terminal automatically adjusts the luminanceof the display screen based on the obtained intensities of the ambientlight detected by the first ambient light sensor and the second ambientlight sensor. For a specific adjustment method, refer to description inEmbodiment 1. Details are not described herein again.

It should be noted that, for processes in which the first area and thesecond area display the black pictures for a plurality of times for aplurality of times, refer to description in Embodiment 1. Details arenot described herein again.

For working processes of the first ambient light sensor and the secondambient light sensor, refer to description in Embodiment 1. Details arenot described herein again.

It should be further noted that, when the terminal has one or moreambient light sensors, the terminal may further increase the displayfrequency, so that there is a phase difference between the displayfrequency and a light source frequency of the ambient light, forexample, a frequency of power-frequency current, to eliminate electricalinterference from the power-frequency current. For example, currentlythe frequency of power-frequency current is 50 Hz or 60 Hz. In otherwords, the flicker frequency of the ambient light may be approximately50 Hz or 60 Hz. A frequency error is generally ±1 Hz. Therefore, thedisplay frequency of the terminal may be set to a value that is not 50Hz or a multiple of 50 Hz, or a value that is not 60 Hz or a multiple of60 Hz. In this way, there is a phase difference between the displayfrequency and a flicker frequency of the ambient light. For example, thedisplay frequency of the terminal is set to 61 Hz, 63 Hz, or the like.

Specifically, the terminal uses a first display frequency when the userdoes not enable the function of automatically adjusting the luminance ofthe screen based on the ambient light. The first display frequency maybe any value. The terminal uses a second display frequency when the userenables the function of automatically adjusting the luminance of thescreen based on the ambient light. There is a phase difference betweenthe second display frequency and the frequency of the power-frequencycurrent, to eliminate impact of a light source generated by thepower-frequency current, and enhance automatic adjustment of anintensity of the screen by the terminal. This improves user experience.

In this way, the terminal detects positions with different intensitiesof the ambient light in each frame, the obtained detection data canreflect an intensity change trend of the ambient light, and thereforethe display screen can be better adjusted based on the detection data.This improves user experience.

It can be understood that, to implement the foregoing functions, theterminal and the like include corresponding hardware structures and/orsoftware modules for performing the functions. A person of ordinaryskill in the art should easily be aware that, in combination with theexamples described in the embodiments disclosed in this specification,units, algorithms, and steps may be implemented by hardware or acombination of hardware and computer software. Whether a function isperformed by hardware or hardware driven by computer software depends onparticular applications and design constraints of the technicalsolutions. A person skilled in the art may use different methods toimplement the described functions for each particular application, butit should not be considered that the implementation goes beyond thescope of the embodiments of the present invention.

In the embodiments of this application, the terminal may be divided intofunctional modules based on the foregoing method examples. For example,each functional module may be obtained through division based on eachcorresponding function, or two or more functions may be integrated intoone processing module. The integrated module may be implemented in aform of hardware, or may be implemented in a form of a softwarefunctional module. It should be noted that, in the embodiments of thepresent invention, division into modules is an example, is merelylogical function division, and may be other division in an actualimplementation.

When functional modules corresponding to various functions are obtainedthrough division, FIG. 13 is a schematic diagram of a possible structureof a terminal in the foregoing embodiments. As shown in FIG. 13, aterminal 1300 includes a display unit 1301, a processing unit 1302, anda first detection unit 1303. The display unit 1301 further includes afirst area 1311 and a second area 1312. The first area 1311 includes anarea used by the first detection unit 1303 to receive ambient light, andthe first area 1312 is at least a part of an area, other than the firstarea 1311, of the display unit 1301.

The processing unit 1302 is configured to control the first area 1311 ofthe display unit 1301 to display a black picture for at least two times.When the first area 1311 displays the black picture, the processing unit1302 is further configured to control the first area 1312 to display animage frame picture. The processing unit 1302 is further configured tocontrol the first area 1311 to display the image frame picture in aninterval between consecutively displaying the black picture in the firstarea 1311 for two times. When the first area 1311 displays the blackpicture, the processor is further configured to obtain an intensity ofthe ambient light detected by the first detection unit. Displaying theblack picture for the at least two times may be periodically displayingthe black picture.

Optionally, the processing unit 1302 is further configured toautomatically adjust luminance of a display screen based on theintensity of the ambient light detected by the first detection unit1303.

Optionally, the processing unit 1302 is further configured to: when theterminal runs a first-type application, increase the interval betweenconsecutively displaying the black picture in the first area for any twotimes, or when the first area always displays the image frame picture,disable an ambient light-based adjustment function.

Optionally, the processing unit 1302 is further configured to: when anobtained movement speed of the terminal is greater than a presetthreshold, increase the interval between consecutively displaying theblack picture in the first area for any two times, or control the firstarea to always display the image frame and disable the ambientlight-based adjustment function.

Optionally, the processing unit 1302 is further configured to: when thefirst area displays the black picture, control, by the terminal, thefirst detection unit 1303 to detect the intensity of the ambient light.The processing unit 1302 is further configured to read the intensity ofthe ambient light detected by the first ambient light sensor.

Optionally, the processing unit 1302 is further configured to: when thefirst area displays the black picture or the image frame picture,control the first ambient light sensor to detect the intensity of theambient light. The processing unit 1302 is further configured to: whenthe first area displays the black picture, read the intensity of theambient light detected by the first ambient light sensor.

Optionally, the processing unit 1302 is further configured to: when adisplay frequency of the terminal is f Hz, control the interval betweenconsecutively displaying the black picture in the first area for twotimes to be greater than or equal to 1/(a×f) seconds, where a is apositive integer greater than or equal to 1.

Optionally, the processing unit 1302 is further configured to controlthe second area to display the black picture for at least two times,where when the second area displays the black picture, the first areadisplays the image frame picture. The processing unit 1302 is furtherconfigured to control, in an interval between consecutively displayingthe black picture in the second area for two times, the second area todisplay the image frame picture.

Optionally, the terminal further includes a second detection unit 1304.The second area includes an area used by a second ambient light sensorto receive ambient light.

Optionally, the processing unit 1302 is further configured to: when thesecond area displays the black picture, obtain an intensity of theambient light detected by the second ambient light sensor. Theprocessing unit 1302 is further configured to automatically adjust theluminance of the display screen based on the intensity of the ambientlight detected by the second ambient light sensor.

Optionally, the processing unit 1302 is further configured to: when thesecond area displays the black picture, control a lower portion of thesecond area to display an n^(th) frame of image frame picture, and anupper portion of the second area to display an (n+1)^(th) frame of imageframe picture; or when the second area displays the black picture,control a lower portion of the second area to display an n^(th) frame ofimage frame picture, and an upper portion of the second area to displaythe n^(th) frame of image frame picture.

Optionally, the processing unit 1302 is further configured to: whencontrolling the first area to display the black picture, turn off alight emitting unit in the first area of the display screen.

Optionally, the processing unit 1302 is further configured to: whencontrolling the second area to display the black picture, turn off alight emitting unit in the second area of the display screen.

Optionally, the processing unit 1302 is further configured to controlthe display frequency and a frequency of power-frequency current of thedisplay screen to form a phase difference.

All related content of the steps in the foregoing method embodiments maybe cited in function descriptions of corresponding functional modules.Details are not described herein again.

Certainly, the terminal 1300 may further include a storage unit,configured to store program code, data, and the like. The terminal 1300may further include a communications unit, used by the terminal tointeract with another device. In addition, functions that can bespecifically implemented by the functional units include but are notlimited to functions corresponding to the method steps in the foregoingexamples. For detailed description of other units of the terminal 1300,refer to the detailed descriptions of the method steps corresponding tothe units. Details are not described herein again.

When an integrated unit is used, the processing unit may be a processorin the terminal. The display unit may be a display module, for example,the display screen. The first detection unit and the second detectionunit may be ambient light sensors. The communications unit may be acommunications module in the terminal, for example, an RF circuit, aWi-Fi module, or a Bluetooth module. The storage unit may be a memory inthe terminal.

FIG. 14 is a schematic diagram of a possible structure of the terminalused in the foregoing embodiments. The terminal 1400 includes aprocessing module 1401, a storage module 1402, and a communicationsmodule 1403. The processing module 1401 is configured to perform controlmanagement on an action of the terminal. The storage module 1402 isconfigured to store program code and data of the terminal. Thecommunications module 1403 is configured to communicate with anotherterminal. The processing module 1401 may be a processor or a controller,for example, a central processing unit (CPU), an MCU, a general-purposeprocessor, a digital signal processor (DSP), an application-specificintegrated circuit (ASIC), a field programmable gate array (FPGA), oranother programmable logical device, a transistor logical device, ahardware component, or any combination thereof. The controller/processormay implement or execute various example logical blocks, modules, andcircuits described with reference to content disclosed in the presentinvention. The processor may also be a combination implementing acomputing function, for example, a combination of one or moremicroprocessors, or a combination of a DSP and a microprocessor. Thecommunications module 1403 may be a transceiver, a transceiver circuit,a communications interface, or the like. The storage module 1402 may bea memory. When the processor executes the program code stored in thememory, the terminal is enabled to perform any method described in theforegoing embodiments.

When the processing module 1401 is the processor (the processor 101shown in FIG. 1a ), the communications module 1403 is an RF transceivercircuit (the radio frequency circuit 102 shown in FIG. 1a ), and thestorage module 1402 is a memory (the memory 103 shown in FIG. 1), theterminal provided in this embodiment of the present invention may be theterminal 100 shown in FIG. 1a . The communications module 1403 mayinclude not only the RF circuit, but also the Wi-Fi module and theBluetooth module. A communications module such as an RF circuit, a Wi-Fimodule, and a Bluetooth module may be collectively referred to as acommunications interface. The processor, the communications interface,and the memory may be coupled together by using a bus.

Example 3

The foregoing embodiments describe the ambient light sensor solution. Anembodiment of this application further provides a plurality of opticalproximity sensor solutions. Specifically, the ambient light sensor inthe solutions provided in the foregoing embodiments may be replaced withan optical proximity sensor, and other components remain unchanged, toobtain the plurality of proximity detection solutions.

In the proximity detection solution provided in this embodiment of thisapplication, a terminal works with an optical proximity sensor tocomplete proximity detection. Specifically, the terminal controls a partof a display screen corresponding to the optical proximity sensor todisplay a black picture, and the terminal obtains a detection result ofan external object by the optical proximity sensor when the part of thedisplay screen displays the black picture. In other words, the opticalproximity sensor detects whether the external object is approaching. Theterminal is controlled based on the detection result. When the terminaldoes not need proximity detection, the terminal may control the part ofthe display screen corresponding to the optical proximity sensor todisplay an image frame picture.

A proximity detection method provided in this embodiment of thisapplication is applied to the terminal. The terminal includes thedisplay screen and a first optical proximity sensor. The first opticalproximity sensor is located under the display screen, and a display areaof the display screen includes a first area and a second area. The firstarea includes an area that is used by the first optical proximity sensorto detect an external object, and the second area is at least a part ofan area, other than the first area, in the display area. When the firstoptical proximity sensor detects the external object by transmitting aninfrared ray, the first area is an area in which the first opticalproximity sensor transmits and receives the infrared ray.

The proximity detection method may include: controlling, by theterminal, the first area to display a black picture for at least twotimes; controlling, by the terminal when the first area displays theblack picture, the second area to display the image frame picture;controlling, by the terminal, the first area to display the image framepicture in an interval between consecutively displaying the blackpicture in the first area for two times; and when the first areadisplays the black picture, obtaining, by the terminal, data detected bythe first optical proximity sensor.

Further, the controlling, by the terminal, the first area to display ablack picture for at least two times includes: controlling, by theterminal, the first area to periodically display the black picture.

Further, a display frequency of the terminal is f Hz, and the intervalbetween consecutively displaying, in the first area controlled by theterminal, the black picture for two times is greater than or equal to1/(a×f) seconds, where a is a positive integer greater than or equal to1.

Further, duration of displaying the black picture each time is firstduration, duration of detecting proximity of the external object by theoptical proximity sensor is second duration, and the first duration isgreater than or equal to the second duration.

Further, the image frame picture is a display user interface presentedby the terminal to a user.

Further, the controlling, by the terminal, the first area to display ablack picture for at least two times includes: controlling, by theterminal, the first area to display N black pictures within a first timeperiod T1.

The controlling, by the terminal when the first area displays the blackpicture, the first optical proximity sensor to detect proximity of anexternal object includes: when M of the N black pictures are displayed,separately controlling, by the terminal, the first optical proximitysensor to detect for M times, where M is less than or equal to N.

Further, the method further includes: controlling, by the terminal, thesecond area to display the black picture for a plurality of times, wherewhen the second area displays the black picture, the first area displaysthe image frame picture; and controlling, by the terminal, the secondarea to display the image frame picture in an interval betweenconsecutively displaying the black picture in the second area for twotimes.

Further, the terminal further includes a second optical proximitysensor, and the second area includes an area that is used by the secondoptical proximity sensor to detect an external object. The methodfurther includes: when the second area displays the black picture,obtaining, by the terminal, data detected by the second opticalproximity sensor.

Further, the second optical proximity sensor is located in a middleportion of the display screen.

Further, the first optical proximity sensor is located in a top portionof the display screen.

Further, the method further includes: when the second area displays theblack picture, controlling, by the terminal, a lower portion of thesecond area to display an n^(th) frame of image frame picture, and anupper portion of the second area to display an (n+l)^(th) frame of imageframe picture; or when the second area displays the black picture,controlling, by the terminal, a lower portion of the second area todisplay an n^(th) frame of image frame picture, and an upper portion ofthe second area to display the n^(th) frame of image frame picture.

Further, the black picture includes a picture whose grayscale value isless than or equal to a preset threshold.

Further, when the terminal controls the first area to display the blackpicture, the terminal turns off a light emitting unit in the first areaof the display screen.

Further, when the terminal controls the second area to display the blackpicture, the terminal turns off a light emitting unit in the second areaof the display screen.

Further, the method further includes: controlling, by the terminal, thedisplay frequency and a frequency of power-frequency current of thedisplay screen to form a phase difference. Further, after the obtaining,by the terminal, data detected by the first optical proximity sensor,the method further includes: if the first optical proximity sensordetects that the external object is approaching, and the terminal is ina call, controlling, by the terminal, to turn off the display screen;orif the second optical proximity sensor detects that the externalobject is approaching, and the terminal is in a call, controlling, bythe terminal, to turn off the display screen.

Further, the method further includes: when the first area displays theblack picture and the image frame picture, the first optical proximitysensor is in a detection state.

The obtaining, by the terminal, data detected by the first opticalproximity sensor includes: when the first area displays the blackpicture, reading, by the terminal, the data that is detected by thefirst optical proximity sensor.

An embodiment of this application further provides a terminal, includinga processor, a memory, a display screen, and a first optical proximitysensor. The first optical proximity sensor is located under the displayscreen, and a display area of the display screen includes a first areaand a second area. The first area includes an area that is used by thefirst optical proximity sensor to detect an external object, and thesecond area is at least a part of an area, other than the first area, inthe display area. The memory and the display screen are coupled to theprocessor. The memory is configured to store computer program code. Thecomputer program code includes a computer instruction, and when theprocessor executes the computer instruction, the terminal is enabled toperform the proximity detection method.

For details about the proximity detection solutions provided in thisembodiment of this application, for example, a position of the sensor,display of the display screen, and working with the sensor to performdetection, refer to description in the foregoing embodiments. Theambient light sensor in the foregoing embodiments is replaced with theoptical proximity sensor.

Example 4

The foregoing embodiments describe the ambient light sensor and theoptical proximity sensor solutions. An embodiment of this applicationfurther provides a terminal including a camera under a screen and aphotographing method thereof. Specifically, in a structure, the ambientlight sensor in the solutions provided in the foregoing embodiments maybe replaced with a front-facing camera, to obtain the terminal includingthe camera under the screen.

According to the photographing method provided in this embodiment ofthis application, after the front-facing camera is turned on, theterminal controls a part of a display screen corresponding to thefront-facing camera to display a black picture. When the terminaldisplays the black picture, the terminal controls the front-facingcamera to perform exposure, to obtain and display a preview picture. Fordetails about displaying the preview picture, refer to the foregoingmethod for displaying the black picture. When the preview picture isdisplayed, the terminal may further periodically obtain a new previewpicture.

The photographing method provided in the embodiments of this applicationis applied to the terminal including the front-facing camera under thescreen. The terminal includes the display screen and the front-facingcamera. The front-facing camera is located under the display screen, anda display area of the display screen includes a first area and a secondarea. The first area includes an area in which a lens of thefront-facing camera is located, and the second area is at least a partof an area, other than the first area, in the display area.

The photographing method may include: turning on, by the terminal, thefront-facing camera; controlling, by the terminal, the first area todisplay a black picture for at least two times; when the first areadisplays the black picture, controlling, by the terminal, thefront-facing camera to obtain a preview image; controlling, by theterminal when the first area displays the black picture, the second areato display an image frame picture; controlling, by the terminal, thefirst area to display the image frame picture in an interval betweenconsecutively displaying the black picture in the first area for twotimes, where the image frame picture displayed in the first area and thesecond area is the preview image obtained by the front-facing camera;receiving a photographing instruction; where the photographinginstruction may be manually triggered by a user, or may be activelytriggered by the terminal in response to some events, for example,capturing a smiling face (when the terminal detects that there is asmiling face in the preview image, the terminal automatically triggersphotographing); and controlling, by the terminal in response to thephotographing instruction, the front-facing camera to performphotographing.

The photographing method includes the foregoing processes of obtainingthe preview image and photographing.

Further, the controlling, by the terminal, the first area to display ablack picture for at least two times includes: controlling, by theterminal, the first area to periodically display the black picture.

Further, a display frequency of the terminal is f Hz, and the intervalbetween consecutively displaying, in the first area controlled by theterminal, the black picture for two times is greater than or equal to1/(a×f)seconds, where a is a positive integer greater than or equal to1.

Further, duration of displaying the black picture each time is firstduration, duration of performing exposure once by the front-facingcamera is second duration, and the first duration is greater than orequal to the second duration.

Further, the image frame picture is a display user interface presentedby the terminal to a user.

Further, the controlling, by the terminal, the first area to display ablack picture for at least two times includes: controlling, by theterminal, the first area to display N black pictures within a first timeperiod T1. when the first area displays the black picture, thecontrolling, by the terminal, the front-facing camera to obtain apreview image includes: when M of the N black pictures are displayed,separately controlling, by the terminal, the front-facing camera toobtain the preview image for M times, where M is less than or equal toN.

Further, the method further includes: controlling, by the terminal, thesecond area to display the black picture for a plurality of times, wherewhen the second area displays the black picture, the first area displaysthe image frame picture; and controlling, by the terminal, the secondarea to display the image frame picture in an interval betweenconsecutively displaying the black picture in the second area for twotimes.

Further, the front-facing camera is located a top portion or a middleportion of the display screen.

Further, the method further includes: when the second area displays theblack picture, controlling, by the terminal, a lower portion of thesecond area to display an nth frame of image frame picture, and an upperportion of the second area to display an (n+1)th frame of image framepicture; or when the second area displays the black picture,controlling, by the terminal, a lower portion of the second area todisplay an nth frame of image frame picture, and an upper portion of thesecond area to display the nth frame of image frame picture.

Further, the black picture includes a picture whose grayscale value isless than or equal to a preset threshold.

Further, when the terminal controls the first area to display the blackpicture, the terminal turns off a light emitting unit in the first areaof the display screen.

Further, when the terminal controls the second area to display the blackpicture, the terminal turns off a light emitting unit in the second areaof the display screen.

Further, the method further includes: controlling, by the terminal, thedisplay frequency and a frequency of power-frequency current of thedisplay screen to form a phase difference.

Further, the method further includes: when the first area displays theblack picture and the image frame picture, the front-facing camera is ina working state; and the controlling, by the terminal, the front-facingcamera to obtain a preview image includes: when the first area displaysthe black picture, reading, by the terminal, the preview image obtainedby the front-facing camera.

An embodiment of this application further provides a terminal, includinga processor, a memory, a display screen, and a front-facing camera. Thefront-facing camera is located under the display screen; a display areaof the display screen includes a first area and a second area. The firstarea includes an area in which a lens of the front-facing camera islocated, and the second area is at least a part of an area, other thanthe first area, in the display area. The memory and the display screenare coupled to the processor. The memory is configured to store computerprogram code. The computer program code includes a computer instruction,and when the processor executes the computer instruction, the terminalis enabled to perform the photographing method.

For details provided in this embodiment of this application, forexample, a position of the front-facing camera, display of the displayscreen, and working with the camera to perform exposure, refer todescription in the foregoing embodiments. The ambient light sensor inthe foregoing embodiments is replaced with the front-facing camera.Certainly, the terminal provided in this embodiment of this applicationmay include both the front-facing camera and the ambient light sensorthat are located under the screen, or may include all the front-facingcamera, the ambient light sensor, and the optical proximity sensor thatare located under the screen.

The foregoing description about implementations allows a person skilledin the art to understand that, for ease of description and brevity,division of the foregoing functional modules is used as an example fordescription. In an actual application, the foregoing functions can beallocated to different modules and implemented according to arequirement. In other words, an inner structure of an apparatus isdivided into different functional modules to implement all or some ofthe functions described above. For a detailed working process of theforegoing system, apparatus, and unit, refer to a corresponding processin the foregoing method embodiments. Details are not described hereinagain.

In the several embodiments provided in this application, it should beunderstood that the disclosed system, apparatus, and method may beimplemented in other manners. For example, the described apparatusembodiment is merely an example. For example, division into the modulesor units is merely logical function division and may be other divisionin an actual implementation. For example, a plurality of units orcomponents may be combined or integrated into another system, or somefeatures may be ignored or not performed. In addition, the displayed ordiscussed mutual couplings or direct couplings or communicationconnections may be implemented by using some interfaces. The indirectcouplings or communication connections between the apparatuses or unitsmay be implemented in electronic, mechanical, or other forms.

The units described as separate parts may or may not be physicallyseparate, and parts displayed as units may or may not be physical units,may be located in one position, or may be distributed on a plurality ofnetwork units. Some or all of the units may be selected based on actualrequirements to achieve the objectives of the solutions of theembodiments.

In addition, functional units in the embodiments of this application maybe integrated into one processing unit, or each of the units may existalone physically, or two or more units are integrated into one unit. Theintegrated unit may be implemented in a form of hardware, or may beimplemented in a form of a software functional unit.

When the integrated unit is implemented in the form of a softwarefunctional unit and sold or used as an independent product, theintegrated unit may be stored in a computer-readable storage medium.Based on such an understanding, the technical solutions of thisapplication essentially, or the part contributing to the prior art, orall or some of the technical solutions may be implemented in the form ofa software product. The software product is stored in a storage mediumand includes several instructions for instructing a computer device(which may be a personal computer, a server, or a network device) toperform all or some of the steps of the methods described in theembodiments of this application. The foregoing storage medium includes:any medium that can store program code, such as a flash memory, aremovable hard disk, a read-only memory, a random access memory, amagnetic disk, or an optical disc.

The foregoing descriptions are merely specific implementations of thisapplication, but are not intended to limit the protection scope of thisapplication. Any variation or replacement within the technical scopedisclosed in this application shall fall within the protection scope ofthis application. Therefore, the protection scope of this applicationshall be subject to the protection scope of the claims.

What is claimed is:
 1. An ambient light detection method, comprising:displaying, by a terminal, a black picture for at least two times in afirst area of a display area of a display screen of the terminal,wherein the terminal includes a first ambient light sensor under thedisplay screen, the display area of the display screen includes thefirst area and a second area, the first ambient light sensor receivesambient light through the first area, and the second area is outside thefirst area, and wherein the black picture is displayed for at least twotimes in the first area during refreshing of one frame of an image framepicture; displaying, by the terminal, the image frame picture in thesecond area when the black picture is displayed in the first area;displaying, by the terminal, the image frame picture in the first areain an interval between displaying the black picture in the first areafor two times; and obtaining, by the terminal, an intensity of theambient light, wherein the intensity of the ambient light is detected bythe first ambient light sensor when the first area displays the blackpicture.
 2. The method according to claim 1, further comprisingdisplaying, by the terminal, the black picture periodically in the firstarea, wherein the black picture continuously moves from one boundary ofthe display area to an opposite boundary of the display area on thedisplay screen during refreshing of the image frame.
 3. The methodaccording to claim 2, wherein the method further comprises: detecting,by the first ambient light sensor, the intensity of the ambient lightwhen the first area displays the black picture and the image framepicture; and reading, by the terminal, the intensity of the ambientlight detected by the first ambient light sensor.
 4. The methodaccording to claim 2, wherein the method further comprises: detecting,by the first ambient light sensor, the intensity of the ambient lightwhen the first area displays the black picture and the image framepicture; and using, by the terminal, the intensity of the ambient lightas detected intensity of the ambient light.
 5. The method according toclaim 1, wherein a display frequency of the terminal is f Hz, and theinterval between displaying the black picture in the first area for twotimes is greater than or equal to 1/(a×f) seconds, wherein a is apositive integer greater than or equal to
 1. 6. The method according toclaim 1, wherein a duration of displaying the black picture each time isgreater than or equal to a duration used by the first ambient lightsensor for detecting the ambient light.
 7. The method according to claim1, wherein the image frame picture includes a display user interfacepresented by the terminal to a user.
 8. The method according to claim 1,wherein further comprising displaying, by the terminal, N black pictureswithin a first time period T1 in the first area; and obtaining, by theterminal using the first ambient light sensor, the intensity of theambient light for M times, when M of the N black pictures are displayed,wherein M is less than or equal to N.
 9. The method according to claim1, wherein the method further comprises: displaying, by the terminal,the black picture for a plurality of times in the second area;displaying, by the terminal, the image frame picture in the first areawhen the black picture is displayed in the second area; and displaying,by the terminal, the image frame picture in the second area in aninterval between displaying the black picture in the second area for twotimes.
 10. The method according to claim 9, wherein the terminal furthercomprises a second ambient light sensor configured to receive ambientlight through the second area, and the method further comprises:obtaining, by the terminal, a second intensity of the ambient light,wherein the second intensity of the ambient light is detected by thesecond ambient light sensor when the second area displays the blackpicture.
 11. The method according to claim 10, wherein the secondambient light sensor is located in a middle portion of the displayscreen.
 12. The method according to claim 10, wherein the method furthercomprises: adjusting, by the terminal, a luminance of the display screenbased on the intensity of the ambient light detected by the firstambient light sensor and the second intensity of the ambient lightdetected by the second ambient light sensor.
 13. The method according toclaim 9, wherein the method further comprises: when the second areadisplays the black picture, displaying, by the terminal, in a firstportion of the second area an nth frame of the image frame picture, andin a second portion of the second area at least one of an nth frame oran (n+1)th frame of the image frame picture.
 14. The method according toclaim 9, wherein when the black picture is displayed in the second area,the terminal turns off a light emitting unit in the second area of thedisplay screen.
 15. The method according to claim 1, wherein the firstambient light sensor is located in an edge portion of the displayscreen.
 16. The method according to claim 1, wherein a grayscale valueof the black picture is less than or equal to a preset threshold. 17.The method according to claim 1, wherein when the black picture isdisplayed in the first area, the terminal turns off a light emittingunit in the first area of the display screen.
 18. The method accordingto claim 1, wherein the method further comprises: controlling, by theterminal, the display frequency and a frequency of a power-frequencycurrent of the display screen to form a phase difference.
 19. The methodaccording to claim 1, wherein after the obtaining, by the terminal, theintensity of the ambient light, the method further comprises: adjusting,by the terminal, a luminance of the display screen based on theintensity of the ambient light.
 20. The method according to claim 1,wherein a period of time in which the terminal displays one blackpicture in the first area is less than a period of time in which theterminal displays one frame of image frame picture.
 21. An ambient lightdetection method, comprising: displaying, by a terminal, a black picturefor at least two times in a first area of a display area of a displayscreen of the terminal, wherein the terminal includes a first ambientlight sensor under the display screen, the display area of the displayscreen includes the first area and a second area, the first ambientlight sensor receives ambient light through the first area, and thesecond area is outside the first area, and wherein the black picture isdisplayed for at least two times in the first area during refreshing ofone frame of an image frame picture; displaying, by the terminal, theimage frame picture in the second area when the black picture isdisplayed in the first area; displaying, by the terminal, the imageframe picture in the first area in an interval between displaying theblack picture in the first area for two times; receiving, by theterminal, a trigger signal that instruct the ambient light sensor tostart detecting the ambient light, in response to the first areadisplaying the black picture; and obtaining, by the terminal, anintensity of the ambient light, after the first ambient light sensordetects the intensity of the ambient light.